I found the source for the following code from an early thread started by Jenny Peters," How do i make multiple selections in a list box".
The code has been modified slightly to suit my arrangement,but for some reason the first part does not work and produces a syntax error in the row
'if listdata.listindex < 0 then
Appears to be something wrong with the "<" bit which i dont follow.
Here is the original code by "AXA"
Private Sub cmdProcessSelections_Click()
____Dim vntIndex As Variant, strValue As String
____
____'--check to see if a selection has been made, give message to user if not, and go no further
____If lstData.ListIndex < 0 Then
________MsgBox "Please select 1 or more items from the list."
________Exit Sub
____End If
____
____'--itterate through each item selected in the listbox, performing required action on each selected item
____For Each vntIndex In lstData.ItemsSelected
________strValue = lstData.ItemData(vntIndex)
________'--do something here with the 'value' for the current selected item...
____Next i
End Sub
The second part works fine,and enables me to select from the listbox into a text box and with a loop get all the selections.
However it would be nice to get the first part working. Can anyone see what is wrong with the first part of the code thanks.
My list box is "list63",and contains 1 column of text.
The code has been modified slightly to suit my arrangement,but for some reason the first part does not work and produces a syntax error in the row
'if listdata.listindex < 0 then
Appears to be something wrong with the "<" bit which i dont follow.
Here is the original code by "AXA"
Private Sub cmdProcessSelections_Click()
____Dim vntIndex As Variant, strValue As String
____
____'--check to see if a selection has been made, give message to user if not, and go no further
____If lstData.ListIndex < 0 Then
________MsgBox "Please select 1 or more items from the list."
________Exit Sub
____End If
____
____'--itterate through each item selected in the listbox, performing required action on each selected item
____For Each vntIndex In lstData.ItemsSelected
________strValue = lstData.ItemData(vntIndex)
________'--do something here with the 'value' for the current selected item...
____Next i
End Sub
The second part works fine,and enables me to select from the listbox into a text box and with a loop get all the selections.
However it would be nice to get the first part working. Can anyone see what is wrong with the first part of the code thanks.
My list box is "list63",and contains 1 column of text.