Yury Merezhkov
asked on
From ListBox to Array Problem
Hi experts,
I'm getting selected items from listbox and populating an array with them. I want to get all of listbox items if nothing is selected and populate the same array with them. What do I need to add to my code? Thanks.
For i = 0 To Me.Client_List.ListCount - 1
If Me.Client_List.Selected(i) Then
c = c + 1
ReDim Preserve Clients(1 To c) As Integer
Clients(c) = Me.Client_List.ItemData(i)
End If
Next i
I'm getting selected items from listbox and populating an array with them. I want to get all of listbox items if nothing is selected and populate the same array with them. What do I need to add to my code? Thanks.
For i = 0 To Me.Client_List.ListCount - 1
If Me.Client_List.Selected(i)
c = c + 1
ReDim Preserve Clients(1 To c) As Integer
Clients(c) = Me.Client_List.ItemData(i)
End If
Next i
ASKER
Nope, method or data member SelCount is not found
ASKER
I also tried ItemsSelected. Didn't work either.
Well, in my vb6 listbox it works, so either
* you have vb.net
* you are using listview
please specify
* you have vb.net
* you are using listview
please specify
ASKER
actually, im using ms access. it has vb 6.3. and i am using listbox for sure. just checked.
vba?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
otherwise:
For i = 0 To Me.Client_List.ListCount - 1
If Me.Client_List.Selected(i) Then
c = c + 1
ReDim Preserve Clients(1 To c) As Integer
Clients(c) = Me.Client_List.ItemData(i)
End If
Next i
if c = 0 then
c = Me.Client_List.ListCount
ReDim Preserve Clients(1 To c) As Integer
For i = 0 To Me.Client_List.ListCount - 1
Clients(i+1) = Me.Client_List.ItemData(i)
Next i
End if
For i = 0 To Me.Client_List.ListCount - 1
If Me.Client_List.Selected(i)
c = c + 1
ReDim Preserve Clients(1 To c) As Integer
Clients(c) = Me.Client_List.ItemData(i)
End If
Next i
if c = 0 then
c = Me.Client_List.ListCount
ReDim Preserve Clients(1 To c) As Integer
For i = 0 To Me.Client_List.ListCount - 1
Clients(i+1) = Me.Client_List.ItemData(i)
Next i
End if
If Me.Client_List.Selected(i)
c = c + 1
ReDim Preserve Clients(1 To c) As Integer
Clients(c) = Me.Client_List.ItemData(i)
End If
Next i