'
' RandomizeArray - Randomize the elements in an array
'
' Author: Joe Strazzere
'
DIM MyArray$(10) ' This is the array to be randomized
' Populate the Array
MyArray$(0) = "a"
MyArray$(1) = "b"
MyArray$(2) = "c"
MyArray$(3) = "d"
MyArray$(4) = "e"
MyArray$(5) = "f"
MyArray$(6) = "g"
MyArray$(7) = "h"
MyArray$(8) = "i"
MyArray$(9) = "j"
ArrayCount = 10 ' The number of elements in the array
' This is the part that randomizes the array
i=0
While i < ArrayCount
j=Random(ArrayCount)
tmp$ = MyArray$(i)
MyArray$(i) = MyArray$(j)
MyArray$(j) = tmp$
i=i+1
Wend
' Display a few elements to show that they are randomized
MsgBox(MyArray$(0))
MsgBox(MyArray$(1))
MsgBox(MyArray$(2))
Your gathering place for information and ideas about Quality Assurance, Testing, and other topics of interest.
May 12, 2009
WinTask - RandomizeArray
Labels:
WinTask