Results 1 to 4 of 4

Thread: [RESOLVED] Randomize problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2007
    Location
    Netherlands
    Posts
    71

    Resolved [RESOLVED] Randomize problem

    Hij guys, i am making a snake-game, and therefore i need to radomize some numbers. I got the function running and it randomizes numers... the only problem is, if i quit the program and start it again... the order in wich they are randomized is always the same.

    like if i randomize between 1 and 6, then the numbers will be for example: 4, 6, 2, 1, 3 ect...
    the next time i run my program it's again 4, 6, 2, 1, 3 ect...
    It's like it will only randomize the first time u run the program:S

    this is the the randomize code i use... its for coordinates:

    Code:
    .Top = 1800 + (Int((17 * Rnd()) + 0)) * 480
    .Left = 1080 + (Int((31 * Rnd()) + 0)) * 480
    please tell we how i can solve this.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Randomize problem

    Use VB's Randomize statement. In your form's load event, try adding this:
    Randomize Timer

    The randomize statement seeds the random generator.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2007
    Location
    Netherlands
    Posts
    71

    Re: Randomize problem

    tnx alot, it worked

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Randomize problem

    Please mark the thread resolved by pulling down the Thread Tools menu and selecting the Mark Thread Resolved item which will let everyone know that you have your answer. (You will need to have JavaScript enabled.)

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