1

How Do I Make Button.click Event Perform both the enter and period(del) keys on the numeric keypad?

Code snippet:

Private Sub frmCalc_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
     Select Case e.KeyCode
        Case Keys.NumPad0
            btn0.PerformClick()
        Case Keys.NumPad1
            btn1.PerformClick()
      'etc.
    End Select
End Sub

Case Keys.Enter and Case Keys.Separator do not work. Nor does anything like Keys.OEMPeriod for the period(del) key.

I've also tried calling the enter key in a KeyPress event etc. But to no avail.

Any ideas? I'm trying to mimic Windows calc.exe for a school project and thought I'd try throwing in a few extras such as numeric keypad functionality.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
legostyle
  • 11
  • 1
  • 2

1 Answers1

0

You can figure this out by yourself.

Set a breakpoint at the beginning of your KeyDown handler in the debugger, press one of those keys, and check the value of e.KeyCode in the Locals window.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • Thanks, much appreciated! This solved the problem for the "period" key. However, pressing the enter key doesn't show any values in the Locals window. Any ideas as to why this might be? – legostyle Nov 03 '09 at 02:25
  • When I set a breakpoint at the beginning of the KeyDown handler in the debugger and start debugging, the Locals window remains completely empty when I press any of the Enter keys on the keyboard, whereas if I press e.g. the a key the Locals window states Name e, Value {KeyData = A{65}} etc. I'm confused as to why the Enter key doesn't seem to respond at this point. – legostyle Nov 03 '09 at 15:43
  • No, strangely enough nothing happens. No yellow arrow appears in front of the set breakpoint nor does any text appear in the Locals window when the Enter key is pressed. – legostyle Nov 03 '09 at 19:08
  • Run Spy++ and check what messages your control receives when you press Num Enter – SLaks Nov 03 '09 at 20:08