Results 1 to 3 of 3

Thread: Need help with the Seed function

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2000
    Location
    Posts
    30
    As posted before on here i have been trying to make a random number generator similar to a dice roller.
    I am using the code

    minr = Text1.Text
    maxr = Text2.Text
    randno = minr + Fix(Rnd * (maxr - minr + 1))
    Label3.Caption = randno

    That way i am able to put in how high i want the number value to be and how low i want it. Unfortuantly with that code it will give you the same number each time you start up the program. I do not really understand the seed function and i would be very thankful if someone could post the code or advice to help me better understand it and use it in my project
    Thanks!
    Dreys
    "Your worst enemy is your greatest teacher."

  2. #2
    Fanatic Member
    Join Date
    Jan 2001
    Location
    Vietnam
    Posts
    613
    Use this statement

    Randomize

    This statement uses the return value from the Timer function as the new seed value

    Hope this helps
    The Bao

  3. #3
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Thumbs up

    Dreys, all you need is juz add one more line of code before you Rnd function.

    Code:
    minr = Text1.Text 
    maxr = Text2.Text 
    
    'Initialize the Random Number generator
    Randomize Timer
    randno = minr + Fix(Rnd * (maxr - minr + 1)) 
    Label3.Caption = randno

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