Random Numbers

Results 1 to 2 of 2

Thread: Random Numbers

  1. #1
    Join Date
    Dec 1969

    Default Random Numbers

    I&#039;m trying to find new things to do in ASP, because im still learning and have only been at this for a month or so of off and on programming. I was wondering if there was a function in ASP that would return a random value. Like in BASIC, etc where did like..<BR><BR>RANOMIZE TIMER<BR>Number = RND(1*6)+2<BR>would return a number between 3 and 9. <BR><BR>Is there anything like this in ASP? Without having to have a long, strung out piece of code telling what the bounds were, etc. I found some scripts, but those are pretty long and i wanted to find a shorter version of this...

  2. #2
    Join Date
    Dec 1969

    Default Look in the left panel of this page...

    (1) Click on the "VBScript Reference" link you find there.<BR><BR>*** BOOKMARK THAT PAGE ***<BR>You will use it often in the future.<BR><BR>(2) Click on "Functions" in the list of topics that appears.<BR><BR>(3) Click on "Rnd" in the list of functions.<BR><BR>Read.<BR><BR>******************* ****<BR><BR>You are incorrect about what you used to do in BASIC.<BR><BR>Your memory is faulty:<BR> RANDOMIZE TIMER<BR> Number = Int( RND() * 6 ) + 3<BR><BR>That returns an integer between 3 and 8. You&#039;d need to multiply by 7 to get an integer between 3 and 9. (You missed the INT call and RND() doesn&#039;t take any argument that is useful.)<BR><BR>In VBScript, the same code works. TIMER is optional; it is supplied automatically if you omit it.<BR><BR><BR><BR><BR>

Posting Permissions

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