Random Numbers

  • Thread starter Thread starter requeth
  • Start date Start date
R

requeth

Hello,

I'm having an issue with random number generation. I am trying to run
the following, but out of 14 times it's generated the same number 12
times, which so happens to be 7563.

randwork1 = Int((9 * Rnd) + 1)
randwork2 = Int((9 * Rnd) + 1)
randwork3 = Int((9 * Rnd) + 1)
randwork4 = Int((9 * Rnd) + 1)
randnumber = randwork1 & randwork2 & randwork3 & randwork4


I thought perhaps since I was running it in an onclick function that
it was somehow caching the results. But reopening the form does not
help. I tried placing it into a macro and trying to pass the variable
back like so:

randnumber = keygen(randnumberfin)

but that gave me a type mismatch though everything is an int.

All I'm trying to get is a 4 digit random number that's random enough
that it has a low probability of duplicating out of 30 consectutive
tries. Any ideas why it is giving me the same number?
 
Before using the Rnd statement, you need to use the Randomize statement to
minimize the chance of repetition.
 
Back
Top