Random Numbers not Random

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
 
L

Linq Adams via AccessMonster.com

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

Frank Wagner

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
 
L

Linq Adams via AccessMonster.com

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

Michael J. Strickland

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.





--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top