[RESOLVED] Unable to generate a random number
I have been looking around for code to randomly generate a number. What I seem to find over and over is this...
Rand = ((High - Low + 1) * Rnd) + Low
or
Rand = Int(Rnd * Upperbound) + Lowerbound
or
Rand = Int(Rnd * high) + low
or
Rand = CInt(Int((high * Rnd()) + low))
No matter what version I use, when I go to generate the number for the first time, it's always the same number. If I repeatedly do it, it does give me different numbers, but I don't want the first number to always be the same. Does anyone have a good random number generator?
Re: Unable to generate a random number
Try Randomize.
You can also set your own seed, ensuring a 'different'(specific to the seed) yet repeatable series of digits.
Code:
Rnd -1
Randomize seed
Re: Unable to generate a random number
Oh yeah, I left out Randomize before generating the number. Thanks FireXtol!