Why doesnt the key delete show up
in keyascii in form_keypress? I
dont need another way to do it though.
Printable View
Why doesnt the key delete show up
in keyascii in form_keypress? I
dont need another way to do it though.
The only possibility is that <DELETE> is not a keyascii character value, while the other ones like < <Backspace > is. Oh, well, I guess I shouldn't give an alternative...
This is indeed pretty strange!
The MsgBox does show up when you press the del (.) button on your numerical pad.. strange...Code:
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyDelete Then
MsgBox "DELETE!"
End If
End Sub
Private Sub Form_Load()
Me.KeyPreview = True
End Sub
What's even more strange is that the Form_KeyDown does recognize the delete key...
By combing the 2 you can capture both keys!Code:Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDelete Then MsgBox "delete"
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyDelete Then MsgBox "delete"
End Sub
Private Sub Form_Load()
Me.KeyPreview = True
End Sub
[Edited by Jop on 10-08-2000 at 06:57 AM]
Hmm..
That is weird..
Thanks! :)
The Delete key doesn't have an ASCII value, but it does have a key code. The reason the number pad delete works is that this registers as an ASCII key (the . char), and the system checks this against the numlock state to decided if it's actually the delete call or a . code.
the key code set in vb allows you to check for every sort of key stroke. The vbKey... prefix matchs the VK_KEY prefix, which stands for "virtual key".
You can work out the rest :)
- gaffa
Jop and Even. Turn your Numlock off and Presto! It works! :)
Thats weird!
why is that?
Gaffa told us already Evan.
When NumLock is one, we are using the numbers; however when Numlock is off, we use what's written at the bottom of the key.