views:

26

answers:

2

How can I get VB.net to work out that i have pressed +-*/ in Keydown events? At the moment i am using a Select Case:

Select Case e.Key
            'Numpad Numbers Keydown Events'
            Case Key.NumPad0
                Display.Append("0")
                txtAnswer.Text = Display.ToString
            Case Key.NumPad1
                Display.Append("1")
                txtAnswer.Text = Display.ToString

However, I can't find a key. thing to work with the numpad function buttons.

i tried using:

Case AscW(Chr(107))
                Display.Append("+")
                txtAnswer.Text = Display.ToString

But it didn't work, can anybody help?

Thanks

Nick

A: 

I don't know off the top of my head, but if I had to find out I'd set a break point in the function, run the program and press each of the keys. That would trigger the break point and I could inspect the e.Key variable with the debugger to learn exactly which key I pressed.

Joel Coehoorn
That is a sound idea Joel, however the watch function doesn't work on "e", it just stays at System.Windows.Input.KeyEventArgs
Nick
@Nick - It should work on e, and you can add your own items to the watchlist or even just mouse over the variable to see it's value.
Joel Coehoorn
A: 

Have you tried Key.Add/Key.Subtract/Key.Multiply/Key.Divide? If that doesn't work (or those don't correspond with the C# .net keys) Try looking for ones prefixed with 'Oem'.

Lunin
Thanks mate! that worked =]
Nick
No problem, glad I could help :D
Lunin