views:

583

answers:

2

I know I can use a quasi-random number generation function/variable called Rnd. However, I've noticed that whenever I used Rnd in my userform, this sequence of numbers always show up:

first iteration: 0.705547511577606 second iteration: 0.533424019813538 ...

As a result, b/c the sequence of numbers showing up are the same every time when I relaunch the userform, it doesn't feel random. Are there other functions in the VBA function set that would make it feel more random? Thanks in advance.

+2  A: 

I don't know a lot about VB but I think you need to seed your number generator. I think Randomize does it for VB.

Luke
+5  A: 

Try adding a single call to Randomize Timer before you do any calls to Rnd. This will seed the random number generator using the time of day.

Travis Beale
Thanks. This suggestion works very well.
stanigator