https://stackoverflow.com/a/31124960/5079799
Notes:
- KeyUp = When Key Is Released
- KeyDown = When Key Is Pressed
- I was able to use
KeyUp
forvbKeyEscape
, but not forvbKeyReturn
. While both worked w/KeyDown
. There for I'll only useKeyDown
moving forward.
Private Sub TextBox2_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = vbKeyReturn Then Call OkButton_Click ElseIf KeyCode = vbKeyEscape Then Call CancelButton_Click End If End Sub