Pick Random Number with no repeat

metrick

Active Member
Licensed User
Longtime User
I have following VBA code in Excel to generator random number between Min and Max numbers and want to duplicate the code in B4A but not success after several hours. Any help would be appreciated.
Here is the code from VBA.

dim Already_Picked as Boolean
dim Random_Number as integer
dim intMin, intMax as integer
dim mloop as integer
dim Array1() as integer
redim Array1(1 to intMax)
redim Already_Picked(1 to intMax)

intMin = 10
intMax = 100

For mloop = intMin To intMax

Do
Random_Number = (((intMAX - 1) * Rnd)
'Random_Number = Rnd(intMin, IntMax) 'B4A
Loop Until Not (Already_Picked(Random_Number))
Array1(mloop) = Random_Number
Already_Picked(Random_Number) = True

Next mloop

For i = LBound(Array1, 1) To UBound(Array1, 1)
For j = LBound(Array1, 1) To UBound(Array1, 1)
If Array1(i) > Array1(j) Then
maxtemp = Array1(i)
Array1(i) = Array1(j)
Array1(j) = maxtemp
End If
Next j
Next i
 
Top