the first item in a listbox has an index of 0 but the listcount is 1 so to get the count of items in a listbox use,
so if there are no entries in the listbox then saying,
VB Code:
ReDim MyArray(List2.ListCount - 1) As Integer
is saying,
VB Code:
ReDim MyArray(- 1) As Integer
which you cant do.
so you need to add items to the listbox or set a condition like this,
VB Code:
Dim MyArray() As Integer 'or whatever type you need
List2.AddItem "vb"
List2.AddItem "forums"
' you need to add something otherwise you'll be redimming to -1
' if you havent adding anything to listbox then
If Not List2.ListCount = 0 Then
ReDim MyArray(List2.ListCount - 1) As Integer
End If