Is it possible to set a seed such that every time i run my program with the function rnd(), the same set of random numbers will be generated each time? And does anyone know how the rnd() function in VBA works? Its it a linear congential generator? Any idea where i can find out more about this generator?
Rnd()
Collapse
X
-
Hi Pumpkin,
I used to have the opposite problem. All the numbers generated were always the same sequence. That's when I discovered that you have to use Randomize to seed the random number generator from the system clock. If you omit Randomize, the numbers will always be generated from the same seed, so just leave it out.
Hope this solves problem
Clay Soyle -
Hi Pumpkin,
Having posted the above, I've just checked up with my VB library and found the following:
Use Randomize(numbe r).
To repeat sequences of random numbers, you must call Rnd with a negative argument immediately before using Randomize with a numeric argument.
Using Randomize with the same value will not repeat the previous sequence.
Clay SoyleComment
Comment