Why are the "random numbers" generated with RND always the same?
No "random numbers" generated by a computer are ever truly random, since they're chosen from a pre-determined set. That's why QBasic will always pick the same numbers with the RND command.|
However, there is a way to work around this: Include the statement RANDOMIZE TIMER somewhere before the RND function in your program. This makes QBasic adjust its random number set based on the computer's internal TIMER. Since the TIMER is constantly changing, so will your random numbers.
Submitted by: Pete on June 22, 2004
Return to the FAQ