Creating random numbers

Results 1 to 3 of 3

Thread: Creating random numbers

  1. #1
    Join Date
    Dec 1969

    Default Creating random numbers

    I need to be able to generate a different random number between <BR>0 and 10 billion every time the page is loaded.

  2. #2
    Join Date
    Dec 1969

    Default RE: Creating random numbers

    &nbsp;<BR>Well, I presume you know that generating the numbers is a piece of cake with VBScript&#039s Randomize statement and RND function. But...<BR><BR><BR>Without keeping track of all numbers previously picked, how can you know for sure that you have picked a "different number" each time?<BR><BR>Sure there&#039s only a small chance of hitting a duplicate, but "small" is not the same as "none".<BR><BR>And *where* will you keep track of all those numbers?

  3. #3
    shaffer Guest

    Default RE: Creating random numbers

    Are you saying with no repeats?<BR><BR>if so, you will need to track all numbers previously used to insure that no dupes occur. <BR><BR>If not, then this simple code will generate an integer for you:<BR><BR>randomize timer<BR>intRand = int(cdbl(rnd) * 10000000000)<BR><BR>If you DO need to track dupes, then it becomes an interesting exercise in algorithm design. And the solution would depend on how many pages you plan on generating over the course of the lifetime of the website.

Posting Permissions

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