View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tim[_44_] Tim[_44_] is offline
external usenet poster
 
Posts: 28
Default Keystroke identification

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?