Lee W, MVP
asked on
VB6 - Combo Control/Drop Down Question
In HTML, if I want to display one thing, but get a different value I would do something like this:
<select name="combo">
<option value=1>John Doe</option>
<option value=2>Jane Smith</option>
<option value=3>Joe Blow</option>
</select>
How can I do the same thing (combo which assigns a value of 1 if John Doe is selected, etc) in VB6, figure using a combo control or maybe a list box?
<select name="combo">
<option value=1>John Doe</option>
<option value=2>Jane Smith</option>
<option value=3>Joe Blow</option>
</select>
How can I do the same thing (combo which assigns a value of 1 if John Doe is selected, etc) in VB6, figure using a combo control or maybe a list box?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I thought so... but the documentation I looked at didn't seem clear on this. Thanks, I'll test things and let you both know.
hi
u can also use NewIndex Property to get newly added entry
'========================= ======
Private Sub Form_Load()
Dim i
For i = 1 To 10
Combo1.AddItem "Item " & i
Combo1.ItemData(Combo1.New Index) = i
Next i
End Sub
'========================= ======
;-)
Shiju
u can also use NewIndex Property to get newly added entry
'=========================
Private Sub Form_Load()
Dim i
For i = 1 To 10
Combo1.AddItem "Item " & i
Combo1.ItemData(Combo1.New
Next i
End Sub
'=========================
;-)
Shiju
ASKER
Ok, working on it again now (if I don't finish today, won't get back to it until Monday). That said, how do I retrieve BOTH the index and the text data?
ASKER
Thanks folks - have to select Erick37 as the answer - The link he provided was REALLY helpful and he did post first.
You can use the Combo1.ItemData(index as integer) property, when index is the index of the item
Add a combo box and paste the following (just select and item) to see how to do it:
Private Sub Combo1_Click()
MsgBox Combo1.ItemData(Combo1.Lis
End Sub
Private Sub Form_Load()
Combo1.AddItem "first"
Combo1.ItemData(0) = 1
Combo1.AddItem "second"
Combo1.ItemData(1) = 2
Combo1.AddItem "third"
Combo1.ItemData(2) = 3
End Sub