Re: How to get random number at same time each day?

From: Sam Low (samlow91xx_at_hotmail.com)
Date: 10/12/04


Date: Tue, 12 Oct 2004 21:17:27 +0800

Thanks for all the responses. I believe 0 second may be the cause of the
problem.

"Russ Holsclaw" <russ@holsclaw.nyet> wrote in message
news:ORxwKk6rEHA.3288@TK2MSFTNGP12.phx.gbl...
> "Sam Low" <samlow91xx@hotmail.com> wrote
> >I have a script that is started by Windows Scheduled Tasks at the same
> >time
> > each day. I have a statement:
> >
> > Randomize(day(Now)*second(now))
> >
> > Then I run a rnd statement and I always get the same number everyday.
> > How
> > can I have some randomness?
>
> The problem, I think, is your poor choice of generating a random-number
> seed.
>
> If you start the program using Scheduled Tasks, and your program starts
> fast enough, then the value of the expression second(now) is probably
going
> to be zero, and zero times anything is still zero. You're using 0 as the
> random number seed. No wonder you get the same series of "random" numbers
> each time.
>
> I believe it was Edsgar Dykstra who said, "The generation of random
numbers
> is too important to be left to chance."
>
> Actually the default "seed" generated internally in VB, works pretty well.
> Don't try to second-guess it by coming up with your own
> not-well-thought-out scheme. Just use "Randomize" without any parameters.
>



Relevant Pages


Loading