|
-
Jun 28th, 2000, 04:13 AM
#1
Thread Starter
Hyperactive Member
Combo1.ItemData problem
I have a text file with FirstNames and LastNames:
"names.txt"
Tom, Johns
Joe, Jordan
Ted, Brown
...etc.
There's a ComboBox & a Label on the form.
I want to read in FirstNames (first column) into a ComboBox, and somehow reference to them LastNames (second column). So when user selects a first name from ComboBox, the corresponding Last name will show on a Label beside it.
example (see names above):
user clicks on Joe in the ComboBox, and Jordan appears in on the Label.
---------------------------------------------------------
MSDN suggests using .ItemData property but I couldn't get it to work with my file access stuff.
MSDN's example of .ItemData
Private Sub Form_Load ()
' Fill List1 and ItemData array with
' corresponding items in sorted order.
List1.AddItem "Judy Phelps"
List1.ItemData(List1.NewIndex) = 42310
List1.AddItem "Chien Lieu"
List1.ItemData(List1.NewIndex) = 52855
List1.AddItem "Mauro Sorrento"
List1.ItemData(List1.NewIndex) = 64932
List1.AddItem "Cynthia Bennet"
List1.ItemData(List1.NewIndex) = 39227
End Sub
Private Sub List1_Click ()
' Append the employee number and the employee name.
Msg = List1.ItemData(List1.ListIndex) & " "
Msg = Msg & List1.List(List1.ListIndex)
Label1.Caption = Msg
End Sub
---------------------------------------------------------
Any suggestions?
Thanx again
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|