I recently got an email from a user who was complaining that his
computer couldn't generate a random number. He had used the
Rnd() function to generate a number between 0 and 1
and then done the calculations to get a number in the range he
needed, but no matter what he tried it was always giving him
the same value.
Well the problem is that computers really aren't very good at
picking random numbers. They actually create sequences of
pseudo-random numbers by using a formula.
The problem is this formula needs a value to get started. It's
called a seed value and, unless you tell it otherwise, your
computer always starts with the same seed value when it's asked for
a random number. The result is that the computer always generates
the same sequence of "random" numbers. (So much for them being random!)
The solution is to call the Randomize() statement
before making your first call to Rnd(). This causes the
computer to initialize the random number generator using a seed value
based on the system timer and will give you numbers that are
a little less predictable.