Singular element of Listbox.Itemsselected collection

hbrems

has no clue...
Local time
Today, 11:24
Joined
Nov 2, 2006
Messages
181
I see a lot of people looping through a Listbox.ItemsSelected collection using a Variant. For example:

Code:
dim varItem as Variant

for each varItem in ListBox.ItemsSelect
     ' Do something here
next

I'm wondering which objects are actually held in this collection (equivalent of ListItem in C#). Thanks!
 
there are no objects in it. the inputs are variants, and those variants serve as references to the indexes of the data type values that you see in listboxes.

i would guess that each collection refers individually to each listbox in an app, because it actually appears to be a property, but not sure 100%
 
Yep, you're right. Just found this on MSDN:

The ItemsSelected collection is unlike other collections in that it is a collection of Variants rather than of objects. Each Variant is an integer index referring to a selected row in a list box or combo box.

Hmm, too bad...
 
You can get the listbox's item in the loop using Listbox.ItemData(varItem) if that's what you're asking.
 
Yep, you're right. Just found this on MSDN:

The ItemsSelected collection is unlike other collections in that it is a collection of Variants rather than of objects. Each Variant is an integer index referring to a selected row in a list box or combo box.

Hmm, too bad...

msdn is not likely to ever be helpful, because the help files there are verbatim from the help menus in the office programs. It's a complete duplication unless you're looking at a thread in a forum. how do you think i found the information I got? ;)
 

Users who are viewing this thread

Back
Top Bottom