...

View Full Version : 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

PremiumBlend
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...

PremiumBlend
03-12-2007, 05:02 PM
Really Interesting...

I don't follow.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum