Randomize Timer 
Author Message
 Randomize Timer

Does anyone know how to increase the variables of the INT(RND* #) -#
What I mean is I need the randomize timer to produce numbers from 1 to
something like 1000. Please help. For Qbasic.
--
~Lamaal Brown http://www.*-*-*.com/ ~brown5/tlbsite



Fri, 26 May 2000 03:00:00 GMT  
 Randomize Timer

Deloris,

        I'm fairly new with QBasic, but this might help.

CLS
RANDOMIZE TIMER
start TIMER
 FOR k% = 1 TO 1000
   product = 1.23 * 4.56
next k%
finish=timer
PRINT " Elasped time:"; finish - start
END

hope this helps
SammyD



Quote:
> Does anyone know how to increase the variables of the INT(RND* #) -#
> What I mean is I need the randomize timer to produce numbers from 1 to
> something like 1000. Please help. For Qbasic.
> --
> ~Lamaal Brown http://www.earthlink.net/~brown5/tlbsite



Tue, 30 May 2000 03:00:00 GMT  
 Randomize Timer

+AD4-Deloris,
+AD4-
+AD4-        I'm fairly new with QBasic, but this might help.
+AD4-
+AD4-CLS
+AD4-RANDOMIZE TIMER
+AD4-start TIMER
+AD4- FOR k+ACU- +AD0- 1 TO 1000
+AD4-   product +AD0- 1.23 +ACo- 4.56
+AD4-next k+ACU-
+AD4-finish+AD0-timer
+AD4-PRINT +ACI- Elasped time:+ACIAOw- finish - start
+AD4-END
+AD4-
+AD4-hope this helps
+AD4-SammyD
+AD4-
+AD4-DELORIS BROWN +ADw-brown5+AEA-earthlink.net+AD4- wrote in article
+AD4APA-348CB18A.52D5+AEA-earthlink.net+AD4-...
+AD4APg- Does anyone know how to increase the variables of the INT(RND+ACo- +ACM-) -+ACM-
+AD4APg- What I mean is I need the randomize timer to produce numbers from 1 to
+AD4APg- something like 1000. Please help. For Qbasic.
+AD4APg- --
+AD4APg- +AH4-Lamaal Brown http://www.earthlink.net/+AH4-brown5/tlbsite
+AD4APg-

Is  Lamaal asking how to generate numbers from 1 to 1000?  If so, you don't
need the TIMER to do that.  To generate a random number from 1 - 1000, use

INT(1000 +ACo- RND) +- 1

Tom Lake



Tue, 30 May 2000 03:00:00 GMT  
 Randomize Timer

Quote:

> Does anyone know how to increase the variables of the INT(RND* #) -#
> What I mean is I need the randomize timer to produce numbers from 1 to
> something like 1000. Please help. For Qbasic.
> --
> ~Lamaal Brown http://www.earthlink.net/~brown5/tlbsite

With UB=<upper boundary> (=1000) and LB=<lower boundary> (=1) the
formula is: RandNoBetweenLBandUB = (UB - LB + 1)*RND + LB
To get integer-numbers use the INT()-function.

ciao
Enno



Tue, 30 May 2000 03:00:00 GMT  
 Randomize Timer

Quote:


> > Does anyone know how to increase the variables of the INT(RND* #) -#
> > What I mean is I need the randomize timer to produce numbers from 1 to
> > something like 1000. Please help. For Qbasic.
> > --
> > ~Lamaal Brown http://www.earthlink.net/~brown5/tlbsite

> With UB=<upper boundary> (=1000) and LB=<lower boundary> (=1) the
> formula is: RandNoBetweenLBandUB = (UB - LB + 1)*RND + LB
> To get integer-numbers use the INT()-function.

Enno is correct, and gives the general formula.  When generating pseudo
random integers from 1 to N the general formula can be reduced to:

  RandomInteger = INT(RND * N) + 1

So the original poster can get random integers from 1 to 1000 by using:

  RandomInteger = INT(RND * 1000) + 1
--
Judson McClendon          This is a faithful saying and worthy of all
Sun Valley Systems        acceptance, that Christ Jesus came into the

(please remove zzz from email id to respond)



Tue, 30 May 2000 03:00:00 GMT  
 Randomize Timer



Quote:
> Does anyone know how to increase the variables of the INT(RND* #) -#
> What I mean is I need the randomize timer to produce numbers from 1 to
> something like 1000. Please help. For Qbasic.

I use this little function....

FUNCTION fRND%( Low%, High% )

  fRND% = ( RND * (High%-Low%) ) + Low%

END FUNCTION

RANDOMIZE TIMER only sets the 'SEED' number to whatever value the TIMER
function returns and is generally used to ensure different results each time
the program is run.

C'ya,

  ____    _    ____      ____  _____
 |  _ \  / \  / ___) __ | ___)(_   _)
 | |_)  / _ \ \____\/  \|  _)   | |
 |____//_/ \_\(____/\__/|_|     |_|

     www.basicguru.com/schullian



Tue, 30 May 2000 03:00:00 GMT  
 Randomize Timer

Quote:
> Does anyone know how to increase the variables of the INT(RND* #) -#
> What I mean is I need the randomize timer to produce numbers from 1 to
> something like 1000. Please help. For Qbasic.

Random numbers up to 1000 work on my qbasic, using the following code;

RANDOMIZE TIMER 'Put this at the start to choose a start position
based on                 'the motherboard clock

x=INT(RND*1000)+1       'Use this to generate a random number from 1 to 1000
                        'and store it in varable x. Change the number
1000                         'to whatever you need.

print x                 'Self explanatory, really.

HTH
Simon.



Tue, 30 May 2000 03:00:00 GMT  
 Randomize Timer

DB>Does anyone know how to increase the variables of the INT(RND* #) -#
DB>What I mean is I need the randomize timer to produce numbers from 1 to
DB>something like 1000. Please help. For Qbasic.

   First, remember to use:

   RANDOMIZE TIMER

   in your program to seed the random number generator before you use the
   RND function in your program. One formula for generating random numbers
   is:

   High% = 1000  ' highest number that can occur
   Low% = 1      ' lowest number that can occur
   ARndNumber% = INT((High% - Low% + 1) * RND + Low%)

   Hope that helps. Good luck!

- Robert

 * OLX 2.1 TD * $1,000,000 reward for finding this man:  



Wed, 31 May 2000 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Randomize Timer?

2. Randomize Timer function not working

3. Randomize Timer function not working

4. Server Timers vs. Windows Timers for RS232 polling

5. system.timers.timer bug found

6. System.Timers.Timer in VB .NET ignores errors

7. Windows Service with System.Timers.Timer

8. Benefits of the timer object, bompared to the timer control

9. better timer than Timer?

10. timer event within a timer event

11. Q: Timer problem (need simple count up timer)

12. Timer interval is depending on code in timer event

 

 
Powered by phpBB® Forum Software