Vb code error

captnk

Registered User.
Local time
Today, 20:53
Joined
Dec 12, 2001
Messages
148
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.
 
Think I have answered my own question,with a little help from some code posted by charityg.
for the line in question I have replaced it with
f Listxx.ItemsSelected.Count=0 then
MsgBox "yyyyyyyyyy"

Seems to work fine
 
For future reference, rather than make your code look ugly with enforced indentation, i.e. using ___________ to make your code appear indented, you can put the Code tags on either end of the code.

[ code ] to open and [/ code ] to close.

(Without the spaces between the square brackets.)
 
Thats noted Mile-o-phile.
HOwever its NOT MY CODE...thats a straight cut from a previous posting by "AXA" on a thread in this site.

yes it is annoying specially when u want to test run it
 

Users who are viewing this thread

Back
Top Bottom