Hey all, newbie to vb here. I've created a listbox (called lst_county) that gets populated from a Select * From Table in Oracle on load. I've set the MultiSelect to 2 -Extended. I've got some code that sends out the select rows from lst_country to a msgbox (all working fine). What i need to do now is to actually put those selected rows into an array that I can later parse into another Select * From Table Where < selected lst_country (i,0)> = some value or < selected lst_country (i,0)> = some value , etc until all selected rows have been parsed.
So can anyone at least help me take the selected values and put them into an array.
Here is my msgbox code.
and here is my first attempt
you'll notice alot of commented out code and that just cause I keep trying different things and see them fail..
i figure once i can get the selected items into a new array, it shouldn't be too much of a problem to parse through those and add them to the SQL WHERE statements.
Thank immensely ahead of time for anyone's help and or direction.
Cheers,
Eric
So can anyone at least help me take the selected values and put them into an array.
Here is my msgbox code.
Code:
Public Function lstbox_array()
Dim i As Long
Dim Msg As String
With frm1.lst_country
For i = 0 To frm1.lst_country.ListCount - 1
If .Selected(i) Then
Msg = Msg & frm1.lst_country.List(i) & vbCrLf
End If
Next i
End With
If Len(Msg) = 0 Then
Msg = “No items selected”
End If
MsgBox Msg
End Function
Code:
Public Function lstbox_array()
Dim i As Long
Dim Msg As String
'Dim listArray()
'Dim j As Long
'Dim vArray
'ReDim listArray(1 To frm1.lst_country.ListCount, 1 To 1)
With frm1.lst_country
For i = 0 To frm1.lst_country.ListCount - 1
If frm1.lst_country.Selected(i) Then
Msg = Msg & Left(frm1.lst_country.List(i), 3) & vbCrLf
'j = j + 1: listArray(j, 1) = frm1.lst_country.List(i, 1)
'vArray(i) = frm1.lst_country.List(i, 1)
'listArray(i, 0) = Left(frm1.lst_country.List(i), 3)
End If
Next i
End With
If Len(Msg) = 0 Then
Msg = "No items selected"
End If
'Debug.Print listArray(i)
MsgBox Msg
End Function
i figure once i can get the selected items into a new array, it shouldn't be too much of a problem to parse through those and add them to the SQL WHERE statements.
Thank immensely ahead of time for anyone's help and or direction.
Cheers,
Eric
Comment