I want to put the contents of a
always changing array into a
listbox... How do you do that?
Printable View
I want to put the contents of a
always changing array into a
listbox... How do you do that?
I don't know if I understood what you're after, but
Dim MyArray(intArrayCount) As String
For i=0 To intArrayCount - 1
MyList.List(i) = MyArray(i)
Next i
for x = 1 to ubound(myArray)
list1.additem myArray(x)
next x
joefoules:
i think the loop should be
for x = 0 to ubound(myArray)
unless you need to discount myArray(0).
I suppose, depends on how you populate the array in the first place.
Look... If thats in a timer though
your gonna never clear the array..
This array changes all the time!
Correct me if I'm wrong, but you have a dynamic array, one that can be a different size each time. Each time the array is assigned something, you want the elements placed in a listbox. Each time the array changes, the listbox clears and repopulates with the new array information? If so:
What'll happen:Code:'This code is NOT verified.
Private Sub List1Populate()
List1.Clear
For X = 0 to UBound(MyArray)
List1.AddItem MyArray(X)
Next X
End Sub
Each time your array changes, call List1Populate. This will clear the listbox and populate it with the current contents of the Array. You could also add this to the same sub your array is being assigned data in, it wouldn't take much work there. More or less, this is exactly the same as the others with the added List1.Clear ...
If this isn't what you're looking for, a more detailed question might be in order ;)
Array's can start at 0 or 1, thus use:
Code:Private Sub List1Populate()
List1.Clear
For X = LBound(MyArray) To UBound(MyArray)
List1.AddItem MyArray(X)
Next X
End Sub
Is the loop
LBnd = LBound(MyArray)
UBnd = UBound(MyArray)
For X = LBnd To UBnd
not more efficient than
For X = LBound(MyArray) To UBound(MyArray)
??