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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Short question on listboxes 1

Status
Not open for further replies.

Thingol

Technical User
Jan 2, 2002
169
Hi all,

I have a listbox with the multiple selections option set to extended. I need to know the listindex for each selected item. I think I need to do something with the itemsselected property of the listbox, but I'm not sure how to do it. This is the code I have now:

Code:
   intTeller = 0
   For Each itm In Me.lstGroepen.ItemsSelected
      'MsgBox (Me.lstGroepen.ListIndex)
      intTeller2 = Me.lstGroepen.ListIndex
      intGroepID(intTeller) = ctl.ItemData(itm)
      strGroepNaam(intTeller) = ctl.Column(0, intTeller4(intTeller))
      intTeller = intTeller + 1
   Next itm

As you can see, I'm trying to use the listindex property to find the index of each item in the selection. It always returns the same row in the list. How can I get the index of each of the selected items in the list?

Best regards,
Martijn Senden.

In the Beginning there was nothing, which exploded.

--Terry Pratchett, Lords and Ladies--
 
A starting point:
For Each itm In Me.lstGroepen.ItemsSelected
MsgBox "Col1=" & Me.lstGroepen.Column(0, Itm) _
& ", Col2=" & Me.lstGroepen.Column(1, Itm)
Next itm


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Looks good, I'll try it tomorrow, at work!

Best regards,
Martijn Senden.

In the Beginning there was nothing, which exploded.

--Terry Pratchett, Lords and Ladies--
 
Thanks PHV, I got it working like a charm using "Me.lstGroepen.Column(1, Itm)".

A star for you!

Best regards,
Martijn Senden.

In the Beginning there was nothing, which exploded.

--Terry Pratchett, Lords and Ladies--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top