The kludgey way
ATTACHED file used.StatesAndCapitals.txtCode:Private Sub Form1_Shown(sender As Object, e As EventArgs) Handles Me.Shown Dim lns() As String = My.Resources.StatesAndCapitals.Split({ControlChars.Cr}) Dim STabbrev As New SortedDictionary(Of String, String) For Each rw As String In lns Dim parts() As String = rw.Split(","c) 'state abbrev. capital STabbrev.Add(parts(0), parts(1)) Next With ComboBox1 .DataSource = New BindingSource(STabbrev, Nothing) .DisplayMember = "Key" .ValueMember = "Value" End With End Sub Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged Debug.Write(ComboBox1.Text) 'DisplayMember Debug.Write(ControlChars.Tab) Debug.WriteLine(ComboBox1.SelectedValue) 'ValueMember End Sub




Reply With Quote