Public Class Form1
Dim Accounts As New List(Of AccountNameKeyPair)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Accounts.Add(New AccountNameKeyPair("fred", "123"))
Accounts.Add(New AccountNameKeyPair("jim", "456"))
Accounts.Add(New AccountNameKeyPair("bob", "789"))
For Each Account As AccountNameKeyPair In Accounts
ComboBox1.Items.Add(Account.AccountName)
Next
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim SelectedText As String = ComboBox1.Items(ComboBox1.SelectedIndex).ToString
For Each Account As AccountNameKeyPair In Accounts
If SelectedText = Account.AccountName Then
'do something with the account number
MsgBox(Account.AccountNumber)
End If
Next
End Sub
End Class
Public Class AccountNameKeyPair
Public AccountName As String
Public AccountNumber As String
Sub New(ByVal AccountName As String, ByVal AccountNumber As String)
Me.AccountName = AccountName
Me.AccountNumber = AccountNumber
End Sub
End Class