Keystroke identification

T

Tim

I have a userform and a textbox. Code is as follows:

Option Explicit
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
' MsgBox KeyAscii & Chr(KeyAscii)
End Sub
Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger,
ByVal Shift As Integer)
MsgBox KeyCode & Chr(KeyCode) & Shift
End Sub

The help documentation indicates that _KeyPress should be used to
interpret keystrokes, but that _KeyUp or _KeyDown should be used to
identify non-printable keys such as <Page Up> or <Insert>. How do
people normally interpret keys when you need more definition than ANSI
definition allows? Are the KeyCodes in _KeyUp keyboard specific?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top