flaviooooo
Programmer
Hey,
I'm looking for a way to create a random number between 2 values, for example between 20 and 40.
At the moment I use this code:
But as you can see, the lower limit will always be 1...
I tried this, to no avail:
Any help would be appreciated
I'm looking for a way to create a random number between 2 values, for example between 20 and 40.
At the moment I use this code:
Code:
Public Function randomvalue(number As Integer)
Dim x As Integer
Randomize ' Initialize random-number generator.
randomvalue = Int((number * Rnd) + 1) ' Generate random value between 1 and number.
End Function
But as you can see, the lower limit will always be 1...
I tried this, to no avail:
Code:
Public Function randomvalue2(top As Integer, low As Integer)
Dim x As Integer
Randomize ' Initialize random-number generator.
randomvalue2 = Int((top * Rnd) + low) ' Generate random value between low and top.
End Function
Any help would be appreciated