VB 6.0 _Listbox MultiSelect

Hello,

I am tring to use a list box control to with the multiselect property. I will be retriving the values that the user selects. This is a sample of my code. It does not work when user selects multiple items on the listbox.

Dim i As Integer

If List1.ListIndex = -1 Then Exit Sub

For i = List1.ListCount - 1 To 0 Step -1

If List1.Selected(i) = True Then
MsgBox List1
strText = List1
End If
Next i
jm1576Asked:
Who is Participating?
 
ultrapascalConnect With a Mentor Commented:
i think what you like something like that

Dim i As Integer

If List1.ListIndex = -1 Then Exit Sub

For i = List1.ListCount - 1 To 0 Step -1

If List1.Selected(i) = True Then
     List1.ListIndex = i
     
    MsgBox List1.Text
   

End If
Next i
0
 
Bob LambersonSoftware EngineerCommented:
I think you want to add each item to the strText lik this....

Dim i As Integer

If List1.ListIndex = -1 Then Exit Sub

For i = List1.ListCount - 1 To 0 Step -1

If List1.Selected(i) = True Then
MsgBox List1
strText = strText & "," & List1
End If
Next i

Bob
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.