简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM