is it possible to -erm- pause a visual basic program for a second or so? there was a pause function in basic, and VB was based on basic...but when you type in pause it doesn't turn blue etc...i did a search on the internet, whcih broguht up the SleepNonBlocking function. whish isn't what i want...and the help's all screwed up too...😛
Originally posted by crythiasi stuck in a for loop, looping for a very large "long" number...but that depends on the speed of the computer (and yeha-i put it as a subroutine)...so i just stuck a button in and told the user to press it...😛
You could put a do-nothing for-next (or Do loop) of arbitrary pause size. Better yet, make it a subroutine, so you can reuse the pause...
You could also do an INKEY$/GETKEY type subroutine that waits for a keypress...
You could also insert a program break if you're still debugging.
Hope that helps.
I've done some programming with Visual Basic, and a command called "sleep" came to mind... did a google search, and this is what I found:
http://www.developerfusion.com/show/119/
A better way than a loop perhaps, because the length of delay is fixed, and doesn't depend on hardware.
-Jarno
Originally posted by crythiaso.k.-so-how do i get the time? and will this work on real PC on apple macs? (i'm doing the program at home, but it'll have to run on the applemacs-but it isn't necessary if it won't...)
:-) you could also use a time subroutine as well. Get current time, get time again until difference is x seconds.
and guess what? i've all but finished the program! it plays you at naughts and crosses! and it actually works!!! i've just gotta perfect it-put in the pause and get the naughts/crosses to flash or something on the winning line...which shouldn't be too hard...hopefully...
EDIT: i asked my dad, who just so happens to do this for a living...(he also just so happened to be asleep at the time 😛). but yeah-this is what i've got for a half-second pause (i tried a timer but it didn't want to work...)
dteTime = Now
Do Until False
If DateDiff("s", dteTime, Now) > 0.5 Then
Exit Do
End If
Loop
Originally posted by geniusThat's clunky. I realize it works, but
o.k.-so-how do i get the time? and will this work on real PC on apple macs? (i'm doing the program at home, but it'll have to run on the applemacs-but it isn't necessary if it won't...)
and guess what? i've all but finished the progr ...[text shortened]... "s", dteTime, Now) > 0.5 Then
Exit Do
End If
Loop
dteTime=Now
Do Until (DateDiff("s", dteTime, Now) > 0.5)
Loop
would be what I'd have done. I mean, why exit do? You've already got the condition to test ... Do Until False is infinite loop, I get it, but it lacks the simplicity of what a Do Until is for.
ETA: But good on ya for those who still pay programmers for lines of code 🙂