Random Number

Results 1 to 2 of 2

Thread: Random Number

  1. #1
    Join Date
    Dec 1969

    Default Random Number

    I have the following code in vbscript to randomly generate 0, 1, 2, or 3<BR><BR>dim randomNum<BR>randomize()<BR>randomNum = Int(4 * rnd())<BR><BR>I am having a hard time figuring out how to prevent a number from repeating and can&#039;t seem to find anything useful online<BR><BR>By repeating, I mean 1,1,2,3,3,0,2,0, etc<BR>but 1,2,3,0,3,1,2,1 is fine<BR>as long as it&#039;s different each time<BR><BR>Can anyone point me in the right direction?<BR><BR>Thank you!

  2. #2
    Join Date
    Dec 1969

    Default RE: Random Number

    If you don&#039;t want repeating numbers, then you are going to have to store your previous random number and check it against the new random number to see if they are the same. If they are the same, then run the random number function again.<BR><BR>HTH

Posting Permissions

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