From: Dave on
Thanks for pointing that out to me. I will have to review the article and
make changes.

Thanks!



"ekkehard.horner" <ekkehard.horner(a)arcor.de> wrote in message
news:473400ea$0$27134$9b4e6d93(a)newsspool1.arcor-online.net...
Dave schrieb:
> Here is some code I use.
>
[... very nice script ...]
>
> Function RandomNumb(intHi, intLo)
>
> Randomize
> RandomNumb = Int((intHi - intLo + 1) * Rnd + intLo)
>
> End Function

Don't restart the random number generator repeatedly.

Eric Lippert comment.
No, you only need to call Randomize _once_, not once per call to Rnd.
Once the system has been seeded, each random number generated acts as
the seed for the NEXT call to Rnd. The RNG has been cleverly designed
so that it does not go into short loops.
In fact, you MUST only call Randomize once. Doing so in a loop, as you
are doing, makes the random number sequence LESS random, not MORE
random.
Why's that? Read on!
The Randomize function seeds the random number generator by passing it
the current system time, a nifty little trick considering the fact
that � in this dimension anyway � each moment in time is unique.

http://blogs.msdn.com/gstemp/archive/2004/02/23/78434.aspx

[...]

From: Dr J R Stockton on
In microsoft.public.scripting.vbscript message <473400ea$0$27134$9b4e6d9
3(a)newsspool1.arcor-online.net>, Fri, 9 Nov 2007 07:34:55,
ekkehard.horner <ekkehard.horner(a)arcor.de> posted:
> The Randomize function seeds the random number generator by passing it
> the current system time, a nifty little trick considering the fact
> that – in this dimension anyway – each moment in time is unique.
>

Not really. Each moment lasts for from 10 to 50 milliseconds,
generally. That's why calling Randomize within such an interval is
**BAD**. Repeatedly calling Randomize at longer intervals is only bad
and pointless.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
First  |  Prev  | 
Pages: 1 2
Prev: File in Use
Next: event supervise