DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Visual Basic 4 / 5 / 6 (http://www.daniweb.com/forums/forum4.html)
-   -   how to have the code pause and then continue with a key stroke (http://www.daniweb.com/forums/thread89164.html)

nanoscientist Sep 10th, 2007 2:14 pm
how to have the code pause and then continue with a key stroke
 
I have written my code in VB6.
I would like the code to pause when variable x = 1, and the program will continue when I hit a key or something of that sort.
Could you give me a hand on this?
ThanX

binoj_daniel Sep 10th, 2007 2:18 pm
Re: how to have the code pause and then continue with a key stroke
 
There are different ways to approach this based on your actuall requirement.

-- You can use a timer and make the timer active when x=1 and inactive when its not.

-- else you can use the sleep and then resume when the value of x changes.

Both methods depends on where you use it.

nanoscientist Sep 10th, 2007 3:32 pm
Re: how to have the code pause and then continue with a key stroke
 
Quote:

Originally Posted by binoj_daniel (Post 431738)
There are different ways to approach this based on your actuall requirement.

-- You can use a timer and make the timer active when x=1 and inactive when its not.

-- else you can use the sleep and then resume when the value of x changes.

Both methods depends on where you use it.

Thank you Binoj for the prompt response.
For my code, either if I use the timer or sleep, x will not change by itself unless the program continues again.
Is there a way that sleep can be deactivated by a key stroke? Surprisingly VB6 doesn't recognizes Sleep!!

binoj_daniel Sep 10th, 2007 3:39 pm
Re: how to have the code pause and then continue with a key stroke
 
See you can use the timer method and activate and deactivate the timer on a key event. To use the Sleep function you have import the API reference in your project.


All times are GMT -4. The time now is 6:41 am.

Forum system based on vBulletin Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
©2003 - 2010 DaniWeb® LLC