Public Class Customer
'Private member variables to hold the data
Private mFirstName As String
Private mLastName As String
Private mAcctNumber As Integer
'Your class constructor
Public Sub New(ByVal fname As String, ByVal lname As String, ByVal acctNum As Integer)
mFirstName = fname
mLastName = lname
mAcctNumber = acctNum
End Sub
'Your public access to your private variables
Public Property FirstName() As String
Get
Return mFirstName
End Get
Set(ByVal Value As String)
mLastName = Value
End Set
End Property
Public Property LastName() As String
Get
Return mLastName
End Get
Set(ByVal Value As String)
mLastName = Value
End Set
End Property
Public Property AcctNumber() As Int32
Get
Return mAcctNumber
End Get
Set(ByVal Value As Int32)
mAcctNumber = Value
End Set
End Property
'Very important. This is what will show in the list box when
'you add the object.
'if you do not override the ToString method
'the name of the object will show in the list box
Public Overrides Function ToString() As String
'This can be whatever you want to show in the listbox
Return LastName & ", " & FirstName
End Function
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim listCustomer As Customer = ComboBox1.SelectedItem
'You can then access its properties
'listCustomer.Firstname
'listCustomer.LastName
'listCustomer.AcctNum
ListBox1.Items.Add(stritem & "has in dex of " & intItem)
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.