Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

# Thread: random 7 digit number

1. ## random 7 digit number

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

• What is happening is you're first creating a random number using this:

Code:
(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:

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

What is happening is you're first creating a random number using this:

Code:
(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:

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

• Really Interesting...
I don't follow.

•

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•