Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random Number Generator

Status
Not open for further replies.

bkesting

IS-IT--Management
Apr 14, 2003
180
US
Hello, I was wondering if anyone has done anything like this before, I am sure someone has.

I am looking to write a random number generator (either as a batch file or vbscript) that will generate 5 random numbers from a range of numbers that I select. Once a number is generated, it needs to be removed from the pool of numbers so it is not selected again. Also, there needs to be the ability to add new numbers to the pool later on down the road.

Anyone ever do something like this?

Thanks.
 
Okay, I think I have figured out the script for the most part. One last question.......How can I get the output of my script into a txt file?

Thanks.
 
Depends on how your script is written. If you want a specific answer, show your code.

Lee
 
Okay, here is my simple code....

*******Start of Code**********

dim upperlimit
dim lowerlimit
dim randomnumber(4)

upperlimit = 500
lowerlimit = 1

For x = 0 to 4
randomize timer
randomnumber(x)=Int((upperlimit-lowerlimit+1)*Rnd)+lowerlimit
Next

msgbox randomnumber(1)&Chr(13)&randomnumber(2)&....randomnumber(4)

**************End of Code*********************

Right now i have my output going to a simple msgbox, I would also like to write the output to a txt file.



 
Use the FSO object to open a file and write to it. This is actually a VBScript question, and if you check out the FAQ part of that forum, or do a search in the forum for FSO, you'll find the information you want.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top