Forum > General

The necessity of using "delay" between "random" calling [SOLVED]

<< < (2/2)

Bart:
Randomize initializes the global variable RandSeed.
It uses a.o. the current system time to calculate it.
If you call randomize twice with only nanoseconds between it, the system time will be the same in both calls.
Therefore RandSeed will be the same after both calls.
RandSeed then is used to calculate the result of Random().
So, both calls to Random() will have the same result.

With the delay, the system time is different after each call, so Random() will be different too.

As others explained: you should call Randomize only once (in the entire program).
The above tries to explain why this is the case.

Bart

pascal111:
I moved "randomize" to "FormCreate", and removed "delays", as @dseligo and @Bart suggested and explained and the program works now appropriately. Thanks everyone!

Navigation

[0] Message Index

[*] Previous page

Go to full version