Results 1 to 3 of 3

Thread: [RESOLVED] Unable to generate a random number

  1. #1

    Thread Starter
    Hyperactive Member BrianPaul's Avatar
    Join Date
    Aug 2007
    Posts
    294

    Resolved [RESOLVED] Unable to generate a random number

    I have been looking around for code to randomly generate a number. What I seem to find over and over is this...

    Rand = ((High - Low + 1) * Rnd) + Low
    or
    Rand = Int(Rnd * Upperbound) + Lowerbound
    or
    Rand = Int(Rnd * high) + low
    or
    Rand = CInt(Int((high * Rnd()) + low))

    No matter what version I use, when I go to generate the number for the first time, it's always the same number. If I repeatedly do it, it does give me different numbers, but I don't want the first number to always be the same. Does anyone have a good random number generator?

  2. #2
    Fanatic Member FireXtol's Avatar
    Join Date
    Apr 2010
    Posts
    874

    Re: Unable to generate a random number

    Try Randomize.

    You can also set your own seed, ensuring a 'different'(specific to the seed) yet repeatable series of digits.

    Code:
    Rnd -1
    Randomize seed

  3. #3

    Thread Starter
    Hyperactive Member BrianPaul's Avatar
    Join Date
    Aug 2007
    Posts
    294

    Re: Unable to generate a random number

    Oh yeah, I left out Randomize before generating the number. Thanks FireXtol!

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