VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Randomize

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 Declarations
none

Rate Randomize


' Ensure a random seed even if the program is started at exactly the same time each day.
Randomize Int(CDbl((Now))) + Timer

Download this snippet    Add to My Saved Code

Randomize Comments

No comments have been posted about Randomize. Why not be the first to post a comment about Randomize.

Post your comment

Subject:
Message:
0/1000 characters