To get the selected item you can use the Text and ListIndex property. They return the text and the index of the selected item respectively.
Var
= Combo1.Text
where var
is a string variable which will contain the
text of the currently selected item
Var
= Combo1.ListIndex
where var
is a string variable which will contain the
index of the currently selected item. Note that as index's start from
0, the first item on the list will return a ListIndex of 0. The following
code displays a message box with the text and listindex of the current
item
' Declare the variables
Dim sText As String
Dim lIndex As Long
' Fill the variables
sText = Combo1.Text
lIndex = Combo1.ListIndex + 1
' Display the message box
Msgbox sText & ", item number " & lIndex & "
is currently selected.
Comments