Random Generator

Results 1 to 2 of 2

Thread: Random Generator

  1. #1
    Join Date
    Dec 1969

    Default Random Generator

    I need to generate a random number. By using the RND funtion I can generate. But the sequence of the numbers that it generate is the same. <BR>Ex., If it generates 15,12,46,89,85,... <BR>whenever we run the program, the same sequence we are getting. <BR><BR>But I want to generate different sequence each time I run the program. In some other language(I think cobol), we have two random generator functions. One like just above and one is dependent on time. It take datetimestamp and uses some algorithm and generates the random number. <BR><BR>Do we have something like that in ASP? <BR>Is there any component available written by somebody already?<BR>I checked at componentsource.com and aspfree.com But no use.<BR>Thanks for your help. Thanks..Hari Potti

  2. #2
    Join Date
    Dec 1969

    Default You forgot RANDOMIZE

    Getting the same sequence of pseudo-random numbers over and over again is done *ON PURPOSE*!!!<BR><BR>Many times, when you do testing, you *want* to have repeatable numbers so you can compare one "run" of a program to the next "run" and be sure you are looking at the same starting point.<BR><BR>So, *UNLESS* you use RANDOMIZE in your ASP page, you *will* get the same sequence!<BR><BR>You should use RANDOMIZE *once per ASP page ONLY*. And you should use it before the first time you call RND.<BR><BR>The best thing to do is usually simply put it at the very top of your ASP page (e.g., where you do all your DIMs?) and forget about it.<BR><BR>Incidentally, all this information *is* in the VBScript reference manual.<BR><BR>Click on "VBScript Reference" in the left panel of this page.<BR><BR>Click on "Functions" in the list of topics that appears.<BR><BR>Scroll down to "RND" in the list of functions and click on it. <BR><BR>Then read, read, read.<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