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

Selecting items is a list box 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I'm trying to go through all the items in a list box and return all that are selected. I put a msgbox in there to see what it returns, and it returns only 1 selected item over and over (so if I select 10 things, the msgbox returns 1 item 10 times). Ideas?? thanks...


iteam as integer
steam as string

For iteam = 0 To lstteam.ListCount - 1
If lstteam.Selected(iteam) = True Then
steam = lstteam.Text
MsgBox (steam)
End If
Next
 
When you assigned the text value of the list box to the
variable, you neglected to reference it with the index
value, so what's happening is the first text value is not being changed as the program runs. That's why you're getting the same value ten times.

try
steam = lstteam(iteam).Text

that should advance the index to the next text value.

Hope that helps.
Happy coding!
 
Anyone have any different thoughts on this? I tried lstteam(iteam).Text, but that didn't work.
 


iteam as integer
steam as string

For iteam = 0 To lstteam.ListCount - 1
If lstteam.Selected(iteam) = True Then
steam = lstteam.list(iteam)
MsgBox (steam)
End If
Next





nick bulka

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top