Determine selected item: cmbo or listbox
Determine selected item: cmbo or listbox
(OP)
I'm trying to create an If...then statement.
What I would like to occur is if user selects an item from the list, a label will display a number (ex: if user selects item "Very good", then lblLabel1.Caption = 5).
Somewhere along the way, I am not understanding how to write the code. I am assuming it has something to do with the index #. (if you can't tell, I'm brand new to programming, trying to teach myself)
Anyone got a suggestion?
Thanks in advance.
What I would like to occur is if user selects an item from the list, a label will display a number (ex: if user selects item "Very good", then lblLabel1.Caption = 5).
Somewhere along the way, I am not understanding how to write the code. I am assuming it has something to do with the index #. (if you can't tell, I'm brand new to programming, trying to teach myself)
Anyone got a suggestion?
Thanks in advance.
RE: Determine selected item: cmbo or listbox
to add a value to the itemdata use
list.itemdata(list.newindex) = value
to retrive the itemdata property use
value = list.itemdata(list.listindex)
James :-)
RE: Determine selected item: cmbo or listbox
x=List1.text
it will return just the text
or x will equal "Very good" in your case.
here is a code example
Private Sub Form_Load()
List1.AddItem "Very Good"
List1.AddItem "Normal"
List1.AddItem "Bad"
End Sub
Private Sub List1_Click()
If List1.Text = "Very Good" Then
' put your code here
End If
End Sub
DougP