|
Post by mopsy on Feb 7, 2006 16:25:50 GMT
My code is as follows
x = INT(RND * 295) + 1 PRINT x;
And everytime I get... 209 I want a random number from 1-295 and it dosen't like me. Help?
|
|
|
Post by mopsy on Feb 7, 2006 22:27:24 GMT
(figured it out) Never mind.
|
|
|
Post by Mikrondel on Feb 8, 2006 5:01:18 GMT
Briefly: There's no such thing as random numbers. At least not in QBasic.
RANDOMIZE lets you pick a "starting point" for QB to go off generating a very unpredictable sequence of numbers from. But if you pick the same starting point, you get the same sequence. If you don't use RANDOMIZE, it uses the same starting point as last time.
TIMER returns the number of seconds elapsed since midnight. Handily, this is usually different every time you run. So RANDOMIZE TIMER is very commonly used to seed the random number generator.
|
|