CCLINT
Thanks for your reply.
I've been playing around with the KeyPress event but can't get it to do what I want.
What I'd like is to have a variable increase from zero to some value, say 10000, while I hold down one key, say the F2 key, and decrease if I hold down another key, say F1.
Can you suggest some code to do this?
domt
If you want to use Function keys use the KeyDown event exactly as CCLINT says - you need to use the predefined values to test against such as vbKeyF1.
Keypress only works on printable keys, not function keys or arrows
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'People who live in windowed environments shouldn't cast pointers.'
Yes, I did make the mistake and wrote Acsii instead of KeyCode:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF1 Then
If Not IsNumeric(Label1.Caption) Then
Label1.Caption = "1"
Else
Label1.Caption = CStr(CLng(Label1.Caption) + 1)
End If
End If
End Sub
But, bigalbigal, why are you suggesting the use of a timer here? What advantage does it have?
If you hold the key long enough, the KeyDown event will repeatedly fire anyways.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.