Rnd()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pumpkin
    New Member
    • Oct 2006
    • 2

    Rnd()

    Is it possible to set a seed such that every time i run my program with the function rnd(), the same set of random numbers will be generated each time? And does anyone know how the rnd() function in VBA works? Its it a linear congential generator? Any idea where i can find out more about this generator?
  • Clay Soyle
    New Member
    • Oct 2006
    • 7

    #2
    Hi Pumpkin,

    I used to have the opposite problem. All the numbers generated were always the same sequence. That's when I discovered that you have to use Randomize to seed the random number generator from the system clock. If you omit Randomize, the numbers will always be generated from the same seed, so just leave it out.

    Hope this solves problem
    Clay Soyle

    Comment

    • Clay Soyle
      New Member
      • Oct 2006
      • 7

      #3
      Hi Pumpkin,

      Having posted the above, I've just checked up with my VB library and found the following:

      Use Randomize(numbe r).

      To repeat sequences of random numbers, you must call Rnd with a negative argument immediately before using Randomize with a numeric argument.

      Using Randomize with the same value will not repeat the previous sequence.

      Clay Soyle

      Comment

      • pumpkin
        New Member
        • Oct 2006
        • 2

        #4
        Thanx for the help. I appreciate it :)

        Comment

        • albertw
          Contributor
          • Oct 2006
          • 267

          #5
          Originally posted by pumpkin
          Thanx for the help. I appreciate it :)
          hi
          try randomize(Timer )

          Comment

          Working...