Results 1 to 5 of 5

Thread: Really Random?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800

    Post

    To randomize i use this:
    Randomize
    MyFile = int((6 + RND) + 1)

    Does this produce a pattern? My friend says yes, I say no

    Steve

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    Post

    You are both right...the Randomize statement gets a seed value from the system time, and assuming you will not be running the code on the same second of every day, it produces a different set of numbers, so they are not completely random, but near enough.

    Without the randomize statement, it would produce the same set of "random" numbers every time.

    Regards

    ------------------
    - Chris
    [email protected]
    If it ain't broke - don't fix it


    [This message has been edited by chrisjk (edited 01-17-2000).]

  3. #3
    Junior Member
    Join Date
    Jan 2000
    Posts
    21

    Post

    It's just like Chris writes. Randomize uses the system time to get a "random" number. You could however write the code like this to make it more clear:

    Randomize Timer
    MyFile = int((6 * RND) + 1)

    BTW, if you type MyFile = int((6 + RND) + 1) then MyFile will always be 7 (maybe this was a typing error?)

  4. #4
    Guest

    Post

    Guess he meant, int((6 + (RND * 10)) + 1)

    ------------------

    Vincent van den Braken
    EMail: [email protected]
    ICQ: 15440110
    Homepage: http://www.azzmodan.demon.nl




  5. #5
    Guest

    Post

    You could also create your own seed:
    Code:
       Dim Password As String
       Dim Seed As Long
       Dim x as Integer
       Temp = Time
       Seed = 0
       If Mid(Temp, 2, 1) = ":" Then
          Seed = Val(Mid(Temp, 1, 1)) + Val(Mid(Temp, 3, 1)) + Val(Mid(Temp, 4, 1)) + Val(Mid(Temp, 6, 1)) + Val(Mid(Temp, 7, 1))
       Else
          Seed = Val(Mid(Temp, 1, 1)) + Val(Mid(Temp, 2, 1)) + Val(Mid(Temp, 4, 1)) + Val(Mid(Temp, 5, 1)) + Val(Mid(Temp, 7, 1)) + Val(Mid(Temp, 8, 1))
       End If
    Then you could:
    Code:
       For x = 1 To Seed
          'Your process here using the Rand function
       Next x
    I use this when generating truly random passwords. You can reseed anytime using the system time, and then just loop through the process the number of seed time using your random function in the loop.

    ------------------
    Boothman
    There is a war out there and it is about who controls the information, it's all about the information.


    [This message has been edited by Boothman_7 (edited 01-18-2000).]

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