Random selection

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: JimT (someone_at_comcast.com)
Date: 11/23/04


Date: Mon, 22 Nov 2004 18:27:32 -0800

I'm working on a script that requires the computer to chose a random number,
either 1, 2 or 3. I looked in a vbscript source book and it gives the
following example:

Randomize
GetRandomNumber = Int((3 * Rnd() + 1)

The author says the Rnd( ) function generates a random number between 0 and
1. The Int( ) function, which returns the integer portion of a number,
executes, multiplying 3 times the randomly generated number and then adds 1
to it. The final result is a randomly generated number with a value between
1 and 3.

If I do the math 3 times 0 is 0 and add 1 is 1. 3 times 1 is 3 plus 1 is 4.
Am I not understanding something in this equation? If not I would
appreciate an explanation. Thanks, Jim



Relevant Pages

  • Math problem
    ... I'm working on a script that requires the computer to chose a random number, ... I looked in a vbscript source book and it gives the ... Thanks, Jim ...
    (microsoft.public.scripting.vbscript)
  • Re: Random selection
    ... > I'm working on a script that requires the computer to chose a random ... > executes, multiplying 3 times the randomly generated number and then adds ...
    (microsoft.public.scripting.vbscript)
  • Re: Foreigner(s)
    ... Rex Harrison knew of the solecisms in the script, of course, but ... chose to turn a blind eye to them....r ... And Sammy Davis, Jr., in a conversation about golf, was once asked, ...
    (alt.usage.english)
  • Re: IE, Firefox, Opera DoS
    ... Each browser comes up with a warning about running the script. ... can chose to run it or not. ...
    (Bugtraq)
  • Importing text files into Access
    ... I have a file browser that opens my directory so I can ... Before I chose my file I run ... this script: MF_Build_Input.cmd ...
    (microsoft.public.access.externaldata)