Multiselect Listbox
Multiselect Listbox
(OP)
I have this code for my multiselect list box. If I select more than one item
the code goes through each of the items twice before it gets out.
If lstCategory.ListIndex = -1 Then Exit Sub
For intCounter = lstCategory.ListCount - 1 To 0 Step -1
If lstCategory.Selected(intCounter) = True Then
Select Case lstCategory.ListIndex
Case 0 ''Ambulance Stations
Call DrawFunction
Case 1 ''Apartments
Call DrawFunction
Case 2 ''Arenas/Stadiums
Call DrawFunction
Case 3 ''Bingo Halls
Call DrawFunction
End Select
End If
Next intCounter
End If
If my list is:
Station
Apartments
Arena/Stadiums
Bingo Halls
If I select
Arena/Stadiums
Bingo Halls
It will loop through Bingo Halls twice before it goes to Arena/Stadiums, which it will do once.
How can I stop this from happening?
the code goes through each of the items twice before it gets out.
CODE
If lstCategory.ListIndex = -1 Then Exit Sub
For intCounter = lstCategory.ListCount - 1 To 0 Step -1
If lstCategory.Selected(intCounter) = True Then
Select Case lstCategory.ListIndex
Case 0 ''Ambulance Stations
Call DrawFunction
Case 1 ''Apartments
Call DrawFunction
Case 2 ''Arenas/Stadiums
Call DrawFunction
Case 3 ''Bingo Halls
Call DrawFunction
End Select
End If
Next intCounter
End If
If my list is:
Station
Apartments
Arena/Stadiums
Bingo Halls
If I select
Arena/Stadiums
Bingo Halls
It will loop through Bingo Halls twice before it goes to Arena/Stadiums, which it will do once.
How can I stop this from happening?





RE: Multiselect Listbox
CODE
If (.ListIndex >= 0) Then
For intCounter = .ListCount - 1 To 0 Step -1
If (.Selected(intCounter) = True) Then
Select Case .Column(0, intCounter)
Case 0
DrawFunction
Case 1
DrawFunction
Case 2
DrawFunction
Case 3
DrawFunction
End Select
End If
Next intCounter
End If
End With
RE: Multiselect Listbox
CODE
RE: Multiselect Listbox
CODE
With lstCategory
If .ListIndex = -1 Then Exit Sub
For intCounter = .ListCount - 1 To 0 Step -1
If .Selected(intCounter) = True Then
'MsgBox lstCategory.List(intCounter)
Select Case .Selected(intCounter)
Case 0 ''Ambulance Stations
Call DrawFunction
Case 1 ''Apartments
Call DrawFunction
Case 2 ''Arenas/Stadiums
Call DrawFunction
Case 3 ''Bingo Halls
Call DrawFunction
End Select
.RemoveItem intCounter
End If
Next intCounter
End If
End With