|
Post by Steve on Jan 29, 2008 17:42:35 GMT
I have been trying to write a small program the would start to count from on up keep going up until I stopped it I don't want it in time I just want it to count up and help on this would be great
|
|
buff1
New Member
Posts: 3
|
Post by buff1 on Jan 29, 2008 23:17:42 GMT
Well if it's not to show the time that is seconds.. that makes it all the easier 10 k&=k&+1 locate 10,10 print k&;" "; for j&=1 to 10 a$=inkey$ if a$<>"" then stop next goto 10
|
|
|
Post by Ildûrest on Jan 29, 2008 23:26:22 GMT
Let me give you some examples:
FOR I = 1 TO 100
NEXT I
Whatever is placed between the FOR and the NEXT lines will execute repeatedly; first it will execute with I being 1; then with I being 2, and so on until I = 100.
For instance you can simply do this:
FOR I = 1 TO 100 PRINT I NEXT I
to display all the numbers from 1 to 100. (They may scroll off the screen but that is another matter and may be dealt with with things like LOCATE, adding a semicolon (;) or comma (,) after PRINT I, or using a delay such as SLEEP 1).
There is also
DO
LOOP
which is a simpler loop; if you want to count "forever" (Eventually the numbers become too big for QBasic to handle, but it will take a long time for that to happen) then you may place something like
I = I + 1
within, to increase the contents of I by 1 each time the loop repeats.
To interrupt the loop with a keypress, you may wish to test INKEY$ against the empty string (""). If it is not equal, then a key is being pressed. You may exit a FOR-loop with EXIT FOR and a DO-LOOP with EXIT DO.
If you want any more help, it would be helpful if you could show us what your program looks like so far.
Ildûrest
|
|