Linky
asked on
Pausing a Program
I have a program with a "For" Loop and I want to pause the loop until "spacebar" is press. Can someone please help me? Code would be nice.
ASKER
Its hard to example. Here is what I am shooting for:
Event 1
Pause Until Space is press
Then go on to Event 2.
Event 1
Pause Until Space is press
Then go on to Event 2.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Are there any alternatives to Form_KeyPress?
ASKER
Are there any alternatives to Form_KeyPress?
Sure! There also is Form_KeyDown and Form_KeyUp, but I assume you do not like them either?
Another alternative to achieve your objective is to use a timer object, but essentially you will still need to know if the space key has been pressed.
Why do you not like the solutions proposed above?
Dabas
Another alternative to achieve your objective is to use a timer object, but essentially you will still need to know if the space key has been pressed.
Why do you not like the solutions proposed above?
Dabas
ASKER
Well I am trying to get it to work, it works in a stand alone program. But not mine.
ASKER
I got it to work. Thanks.
One last thing, we forgot to say....if you use a keydown or keypress event set the value to zero so that a space won't appear somwhere else in the current field Keyascii =0.
Private Sub Form_KeyPress(Keyascii As Integer)
If Keyascii = 32 Then
Keyascii = 0 ' DO THIS
bCancel = True
End If
End Sub
Private Sub Form_KeyPress(Keyascii As Integer)
If Keyascii = 32 Then
Keyascii = 0 ' DO THIS
bCancel = True
End If
End Sub
ASKER
Ok, thanks.
hi,
This code is fine. But when u run this, my Taskmanager always shows CPU Usage as (100%). Wont this make harm to the computer.?
This code is fine. But when u run this, my Taskmanager always shows CPU Usage as (100%). Wont this make harm to the computer.?
kcm76,
What is shown is as an example only. You certainly wouldn't just have a Do/Loop doing nothing. The presumption is that there would be programming code to do some processing and upon completion of one iteration of that process instead of dropping out of the loop, the process would return to the top and begin executing again.
The original question was how to be inside a looping structure and then break out of it when the program operator pressed the SpaceBar.
Hope this helps clarify your concern.
Sweat
What is shown is as an example only. You certainly wouldn't just have a Do/Loop doing nothing. The presumption is that there would be programming code to do some processing and upon completion of one iteration of that process instead of dropping out of the loop, the process would return to the top and begin executing again.
The original question was how to be inside a looping structure and then break out of it when the program operator pressed the SpaceBar.
Hope this helps clarify your concern.
Sweat
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 32 Then
MsgBox "Wpace bar pressed!"
End If
End Sub
Hop this helps:~)