|
-
Jul 21st, 2001, 01:55 PM
#1
Thread Starter
Addicted Member
Waiting for keypress...
How would I pause my coding at certain intervals to wait for the user to press the spacebar? Also how can I pause the coding for a certain amount of time before continuing?
Thanking you in advance...
100 posts... All of them have been "How Do I's", "Can You's", "HELP ME!!'s"...
Still, at least they've been relevant..
-
Jul 21st, 2001, 02:14 PM
#2
Put in an endless loop untill a keyboard event happens.
x=0
do while x<>1
if keyboard event happens then
x=1
end if
loop
-
Jul 21st, 2001, 02:51 PM
#3
Fanatic Member
It would be better to do this. If you just make an endless loop, you may end up locking the system completely.
VB Code:
'in a module
Public Declare Function GetKeyState Lib "user32" (ByVal vKey As Long) As Long
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Const VK_SPACE As Long = &H20
'wherever you want to wait until space is hit, add this
Do Until GetKeyState(VK_SPACE) And &H8000: DoEvents: Loop
'to stop your program for a certain period of time, like to halt while displaying something
Sleep 5000 'stop for 5 seconds
I'm baaaack...
VB5 Professional Edition, VC++ 6
Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se
I feel special because I finally figured out how to loop midis: Post link
I'm a fanatic too 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|