Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to set listindex of a combobox

Status
Not open for further replies.

hiatus

Programmer
Apr 10, 2001
6
US
I have a combobox with a few items having itemdata, basically i use the itemdata to do some checks, also the combobox text is loaded from another form

cbo(cbo_start).text = frm1.txt(0).text

now I have a condition which says if cbo(cbo_start).itemdata(cbo(cbo_start).listindex) > 0 then do something

but if I set the text I get listindex = -1, is there any way I can get the listindex as the listindex of the selected item???
 
You will need to loop through the items, using the .listcount property, and then check either the .list, .itemdata or .selected property to find what you wan then set the .listindex property to the loop variable value. For example,
Code:
Dim i As Integer

For i =0 to Combo1.Listcount-1
   if Combo1(i).Selected = True then
      combo1.listindex=i
   end if
next i


zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top