CodeItBetter Programming Another VB Programming Blog

How to return an array with all the selected items in a ListBox

Posted on August 19, 2011
1
2
3
4
5
6
7
8
9
10
11
12
'Controls - How to return an array with all the selected items in a ListBox
Public 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
Filed under: Controls Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.