...

# random 7 digit number

esthera
03-11-2007, 02:34 PM
i'm using
Randomize ' Initialize random-number generator.
rnumber= Int((9999999 * Rnd) + 1000000)

to generate a random 7 digit number -- but sometimes it is not 7 digits but 8

why? and how can I get a random 7 digit number

03-11-2007, 06:57 PM
What is happening is you're first creating a random number using this:

(9999999 * Rnd)

which creates a number between 0 and 9999999, if the number generated is over 9000000, by adding 1000000 to it, it will be an 8 digit number.

trying this code:

Randomize ' Initialize random-number generator.
rnumber= Int((8999999 * Rnd) + 1000000)

SSJ
03-12-2007, 10:50 AM
What is happening is you're first creating a random number using this:

(9999999 * Rnd)

which creates a number between 0 and 9999999, if the number generated is over 9000000, by adding 1000000 to it, it will be an 8 digit number.

trying this code:

Randomize ' Initialize random-number generator.
rnumber= Int((8999999 * Rnd) + 1000000)

Really Interesting...