If you dimension an array without specifying how many elements it has (Dim MyArr() As Integer), then you cna add elements to it dynamically.
Changing the size of an array deletes the array's contents unless you explicitly tell
VB to preserve the results:
Code:
Dim MyArr() As Integer
ReDim MyArr(5) ' The array will have 6 elements equal
' to zero (the default value of an Integer)
ReDim Preserve MyArr(5) ' If the array had any non-zero elements,
' they are still there (as long as they
' were between 0 and 4, of course...)
So, using this, you can add elements to your array everytime you generate a new random number:
Code:
Redim Preserve MyArr(UBound(MyArr + 1))
Code:
MyArr(UBound(MyArr)) = <YourNewValue>