Random Number - Easy

# Thread: Random Number - Easy

1. Senior Member
Join Date
Dec 1969
Posts
661

## Random Number - Easy

&nbsp;<BR>I read on the Web that I can get a random number with this<BR><BR>RandomNumber = Int(Rnd * TopNumber) + BottomNumber<BR><BR>Say the TopNumber = 2300<BR>and the BottomNumber = 586<BR><BR>I will get a number inbetween...<BR><BR>However this gives me a number greater than 2300.<BR>must be easy

2. Senior Member
Join Date
Dec 1969
Posts
96,118

...and if you want *good* info, you should got to the *real* source.<BR><BR>Click on "VBScript Reference" in the left panel of this page.<BR><BR>[And bookmark that page!]<BR><BR>Click on "Functions" in the list of topics that appears.<BR><BR>Click on "RND" in the list of functions that appears.<BR><BR>Read.<BR>

3. Junior Member
Join Date
Dec 1969
Posts
20

## RE: Random Number - Easy

Try:<BR><BR>varRandomNumber = Int(Rnd * (TopNumber-BottomNumber)) + BottomNumber<BR><BR>Don&#039;t forget to put Randomize() above this so that you get different numbers each time.<BR><BR>Ray at home<BR>

4. Senior Member
Join Date
Dec 1969
Posts
661

## Figured It Out

RandomNumber = Int((TopNumber- BottomNumber + 1) * Rnd + BottomNumber)

5. Senior Member
Join Date
Dec 1969
Posts
96,118

## Nope, not right...

...go read the VBScript docs. You are missing one thing.<BR><BR>

6. Junior Member
Join Date
Dec 1969
Posts
20

## RE: Nope, not right...

Oh yeah.<BR>+1<BR>;]<BR><BR>Ray at home

#### Posting Permissions

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