Home > How-To Library > Arrays, Collections, Lists
How to store all the selected items in a ListBox in an array
**************************************************************** * © 2007 CodeItBetter http://www.codeitbetter.com * * This notice MUST stay intact for legal use * **************************************************************** ' 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
If you would like to submit your code here please us. Do not forget to mention your name. We are always thankful to each and everyone of you who submitted their code here.