CodeItBetter Programming Another VB Programming Blog

How to store all the selected items in a ListBox in an array

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
'Arrays, Collections, Lists - How to store all the selected items in a ListBox in an array
' Returns an array with all the selected items in a ListBox
Function SelectedListItems(lst As ListBox) As String()
    Dim I As Long, j As Long
    ReDim result(0 To lst.SelCount) As String
    For I = 0 To lst.ListCount - 1
        If lst.Selected(I) Then
            j = j + 1
            result(j) = lst.List(I)
        End If
    Next
    SelectedListItems = result
End Function
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.