-
Nov 7th, 2000, 02:51 PM
#1
Thread Starter
Addicted Member
Can any one tell me why this isn't working?
Code:
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyUp Then
KeyAscii = 0
Debug.Print "Up Key Pressed"
Beep
End
If KeyAscii = vbKeyDown Then
KeyAscii = 0
Debug.Print "Down Key Pressed"
Beep
End If
End Sub
This is just a test i wrote for another program just to see if the keys etc work, but nothing happens no beeps and no text is being printed in th debug dialog...help?
I have also tried the keyDown & keyUp procedures still nothing.
-
Nov 7th, 2000, 03:21 PM
#2
Fanatic Member
Try this
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If (KeyCode = vbKeydown) Then
MsgBox "Down key pressed"
End If
If (KeyCode = vbKeyup) Then
MsgBox "Up key pressed"
End If
End Sub
Cheers
Ray
-
Nov 7th, 2000, 03:28 PM
#3
Lively Member
The first thing that you have to do is to set the KeyPreview property to True then the second thing is that your code will work fine if you have controls like textbox or listbox in the form.If you click inside that then you will get the output desired by you....
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
|