Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

enbaling and desabling key press

Status
Not open for further replies.

shaminda

Programmer
Jun 9, 2000
170
US
I have a program in which when the user enters F9 a procces starts, and when the user presses F3 the procces stops. Right now if the user enters F9 in the middle of the process it will start all over. How do I lock the F9 key after user enters it once? And the F9 key has to be enabled again after user enters F3. How do I do this.
 
Whereever you handle the F3/F9 in the forst place, put a module/form level variable or STATIC variable to indicate what Fx key is in control.
Code:
Private Sub Form_KeyUp(Keycode As Integer, Shift As Integer)
    STATIC intKeyCode as integer
    Select Case Keycode
    Case intKeyCode
        exit sub
    Case vbKeyF9
        intKeyCode = KeyCode
        Call DoF9Stuff
    Case vbKeyF3
        intKeyCode = KeyCode
        Call DoF3Stuff
    Case else
        Msgbox "Invalid ....."
        exit sub
     end select
end sub      [URL unfurl="true"]WWW.VBCompare.Com[/URL]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top