by Tom Rezek (1 Submission)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating:
(2 Votes)
Ensure that the random number generator is seeded properly.
Assumes
Using the VB statement "Randomize" by itself to seed the random number generator implicitly means "Randomize Timer", with the timer function returning the number of seconds that have elapsed since 12:00 A.M. (midnight). If a program is started at roughly, or worse, launched at the same time each day, the timer could return the same seed each day. To avoid this problem, use a seed based on the date and time.
API Declarationsnone
' Ensure a random seed even if the program is started at exactly the same time each day.
Randomize Int(CDbl((Now))) + Timer