Auto Select Items in an Extended Listbox

Clut

Registered User.
Local time
Today, 15:06
Joined
May 5, 2010
Messages
29
Hi,

I have a list of values in a table, some of which correspond to a list of values in the first column of an extended listbox.

when the form loads, I cycle through the list of values in the table, and I then want to check each value in the table against the values in the first column of the listbox, and if a match is found, select that row in the listbox.

At the end, I should have some rows in the listbox selected, and some rows not selected, depending on how many matching values there were in the table.

Can anyone help with this???

Thanks
 
You would use the selected property of the listbox, but you would have to run through each item in the listbox (per value in form) and select the item then break out of the loop if the item is found. So something like this:
Code:
dim i as long

for i = 0 to listbox1.listcount - 1
     if ValueFromForm = listbox1.column(0, i) then
          listbox1.selected(i) = True
          exit for
     end if
next
If you have a long list this could end up being quite slow.
 
Thanks,

Worked perfectly.
 

Users who are viewing this thread

Back
Top Bottom