Go back
pause function

pause function

General

g
Wayward Soul

Your Blackened Sky

Joined
12 Mar 02
Moves
15128
Clock
04 Mar 04
Vote Up
Vote Down

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...😛

c
Multiple OS User

Bonita Springs, FL

Joined
21 Mar 01
Moves
3062
Clock
08 Mar 04
Vote Up
Vote Down

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.

g
Wayward Soul

Your Blackened Sky

Joined
12 Mar 02
Moves
15128
Clock
09 Mar 04
Vote Up
Vote Down

Originally posted by crythias
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 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...😛

P

Joined
31 Jul 03
Moves
6355
Clock
09 Mar 04
Vote Up
Vote Down

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

c
Multiple OS User

Bonita Springs, FL

Joined
21 Mar 01
Moves
3062
Clock
09 Mar 04
Vote Up
Vote Down

:-) you could also use a time subroutine as well. Get current time, get time again until difference is x seconds.

g
Wayward Soul

Your Blackened Sky

Joined
12 Mar 02
Moves
15128
Clock
16 Mar 04
1 edit
Vote Up
Vote Down

Originally posted by crythias
:-) you could also use a time subroutine as well. Get current time, get time again until difference is x seconds.
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 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

c
Multiple OS User

Bonita Springs, FL

Joined
21 Mar 01
Moves
3062
Clock
17 Mar 04
1 edit
Vote Up
Vote Down

Originally posted by genius
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
That's clunky. I realize it works, but

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 🙂

Cookies help us deliver our Services. By using our Services or clicking I agree, you agree to our use of cookies. Learn More.