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...
Printable View
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...
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
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