Results 1 to 6 of 6

Thread: Bad Random Function?

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715

    Bad Random Function?

    Hi,

    I have a function that generates a random 6-Digit Number, so there should be at least 6^10 possible combinations. However I ran the function 1000 times and I got the same numbers 3 or 4 times. Here is my code:

    VB Code:
    1. <%
    2.     Function RandomPW()
    3.         For X = 1 To 6
    4.             Randomize
    5.             strPW = strPW & CHR(Int((9 * Rnd) + 48))
    6.         Next
    7.         RandomPW = strPW
    8.     End Function
    9.    
    10.     for i = 0 to 1000
    11.         response.write RandomPW() & "<br>"
    12.     next
    13. %>

    After I got the result, I put it into Excel and sorted it. Attached is the list that I was returned, after I sorted it in Excel.

    Am I doing something wrong as far as generating random numbers?

    thanks,

    Dimava
    Attached Files Attached Files
    NXSupport - Your one-stop source for computer help

Posting Permissions

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



Click Here to Expand Forum to Full Width