Random Numbers not Random

  • Thread starter Thread starter Frank Wagner
  • Start date Start date
F

Frank Wagner

When I create random numbers for an application with the following code, they
do not appear to be truely random.

Me.RandomNumber = Int(9 * Rnd + 1) ' Random Number 1-9

If I have two users setting side by side, they frequently get the same
results when they start up

Am I missing somthing?

Any help would be appreciated
 
You're only going to get so much "randomness" with a limit of 1-9. What
exactly are you trying to do with this?

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 
Linq:

I create software for schools. When generating tests, I have 10 questions
for each category, and want to assemble random tests by assembling a packet
of random questions from each category. They all were starting out with the
same random question. It looks like the randomize statement that Al
suggested might solve the problem.

Thanks
 
OK. Using the Randomize statement does just that, ***randomizes*** the
initial seed for Rnd, which is why it solved your problem.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 
Frank Wagner said:
When I create random numbers for an application with the following
code, they
do not appear to be truely random.

Me.RandomNumber = Int(9 * Rnd + 1) ' Random Number 1-9

If I have two users setting side by side, they frequently get the same
results when they start up

Am I missing somthing?

Any help would be appreciated


You are obtaining pseudo-random numbers with this function. Quoting MS
Help:

"The value of number determines how Rnd generates a random number:

For any given initial seed, the same number sequence is generated
because
each successive call to the Rnd function uses the previous number as a
seed
for the next number in the sequence.

Before calling Rnd, use the Randomize statement without an argument to
initialize the random-number generator with a seed based on the system
timer."


The Rnd function is designed so that you can generate a repeatable set
of pseudo-random numbers for testing purposes.

If you want a truly random sequence of numbers you need to use the
Randomize function as a previous posters have mentioned.





--
 
Back
Top