Combobox Item Number

T

Todd Huttenstine

Lets say there are 20 items that can possible be chosen
out of a combobox. Lets say I selected the
value "April". The value April is the 4th item in the
combobox. What is the code that will return 4? I just
need a code that will return the location number of the
value that I selected.


Thank you
Todd Huttenstine
 
V

Vasant Nanavati

ComboBox1.ListIndex + 1

(The index is zero-based, so the first item has a ListIndex of 0).
 
H

Harald Staff

Hi Todd

Combo1.ListIndex + 1

(since item 1 is listindex 0 )

HTH. Best wishes Harald
 
K

kkknie

If you mean VB, you can use the listindex

i = Combo1.Listindex

One thing to note is that the listindex property is zero based, so i
you are looking for the fourth item in the list, it will have
listindex of 3.

Also, to get the value for an item where you know the listindex, yo
would use:

strValue = Combo1.List(1)

Which would retrieve the second value in your list.

K

Edit: Way too slow I see..
 
Top