
February 22nd, 2007, 05:02 AM
|
|
Registered User
|
|
Join Date: Jan 2007
Posts: 4
Time spent in forums: 1 h 50 m 49 sec
Reputation Power: 0
|
|
Creates random array
Code:
Function RandomArray(alen, LBound, UBound)
Dim i, j, exists, nextrand, newrandom, result
result = Null
If (alen >= 1) Then
ReDim result(alen - 1)
Randomize
For i = 0 To alen - 1
nextrand = True
Do While nextrand
exists = False
newrandom = Int((UBound - LBound + 1) * Rnd + LBound)
For j = 0 To i - 1
exists = exists Or (result(j) = newrandom)
Next
If (Not exists) Then
nextrand = False
result(i) = newrandom
End If
Loop
Next
End If
RandomArray = result
End Function
sourcecodesworld.com
Last edited by nofriends : February 22nd, 2007 at 06:30 AM.
Reason: added [code][/code] tags
|