Posted by: Sourav | August 21, 2016

List Object Example VB,VB Teacher Sourav


Option Strict On
Option Explicit On
Imports System
Module Module1

Sub Main()
Dim count As Integer = 0

Dim emplist As New List(Of Employee)
emplist.Add(New Employee())

emplist(count).manipulateid = 0
emplist(count).manipulatename = “Sourav”
emplist(count).manipulateexperience = 5
emplist(count).manipulatesalary = 5000
count += 1

emplist.Add(New Employee())

emplist(count).manipulateid = 1
emplist(count).manipulatename = “Sougata”
emplist(count).manipulateexperience = 5
emplist(count).manipulatesalary = 5000
count += 1
emplist.Add(New Employee())

emplist(count).manipulateid = 2
emplist(count).manipulatename = “Subrata”
emplist(count).manipulateexperience = 6
emplist(count).manipulatesalary = 6000

count += 1
emplist.Add(New Employee())

emplist(count).manipulateid = 3
emplist(count).manipulatename = “Subir”
emplist(count).manipulateexperience = 2
emplist(count).manipulatesalary = 2000

Dim emp1 As Employee = New Employee
emp1.promoteemployee(emplist)
Console.ReadLine()
End Sub

End Module

 

Public Class Employee
Private id As Integer
Private name As String
Private salary As Integer
Private experience As Integer

Public Property manipulateid As Integer
Set(ByVal id As Integer)
Me.id = id

End Set
Get
Return Me.id

End Get

End Property

Public Property manipulatename As String
Set(ByVal name As String)
Me.name = name
End Set
Get
Return Me.name

End Get

End Property

Public Property manipulatesalary As Integer
Set(ByVal salary As Integer)
Me.salary = salary

End Set
Get
Return Me.salary

End Get

End Property
Public Property manipulateexperience As Integer
Set(ByVal experience As Integer)
Me.experience = experience

End Set
Get
Return Me.experience

End Get

End Property

Public Sub promoteemployee(ByVal employeelist As List(Of Employee))

For Each empobj As Employee In employeelist
If empobj.manipulateexperience >= 5 Then
Console.WriteLine(empobj.manipulatename & ” got promoted”)

End If
Next

End Sub

End Class

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: