VB.NET 2008 - How Do I Make Button.click Event Perform both the enter and period(del) keys on the numerical keyboard?

2.5k views Asked by At

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.

1

There are 1 answers

4
SLaks On

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.