foobarr
asked on
mimic a keyboard keypad
i am trying to figure out how to program using a touch screen monitor
so right now i have created a keypad 0 - 9 using command buttons
cmdKeypad1
cmdKeypad2, etc..
and i have a couple text boxes
txtEmployeeId
txtOrderNo
originally on the click of event of cmdKeypad1 I was going to go
me.txtEmployeeID.appendTex t("1")
but then i realized that i need to also use the keypad as a method of input to txtOrderNo
so then i figured out that I need to mimic this keypad to act as the same way as you would use it on the keyboard
and as well i need to make sure that i do not lose focus on the textbox when i start clicking the keypad buttons
so right now i have created a keypad 0 - 9 using command buttons
cmdKeypad1
cmdKeypad2, etc..
and i have a couple text boxes
txtEmployeeId
txtOrderNo
originally on the click of event of cmdKeypad1 I was going to go
me.txtEmployeeID.appendTex
but then i realized that i need to also use the keypad as a method of input to txtOrderNo
so then i figured out that I need to mimic this keypad to act as the same way as you would use it on the keyboard
and as well i need to make sure that i do not lose focus on the textbox when i start clicking the keypad buttons
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
okay i looked over this and i figured out that it uses the text value of the buttons
Right...so cmdKeypad0 has "0" on it, cmdKeypad1 has "1" on it, etc...
Whenever one of your TextBoxes gets the focus in the GotFocus() event, we set the form level variable "lastControl" equal to whatever TextBox just got the focus.
Now when one of our KeyPad buttons is pressed, we switch back to whatever control last had the focus via our "lastControl" variable and then send the keystroke...
Make sense?
Whenever one of your TextBoxes gets the focus in the GotFocus() event, we set the form level variable "lastControl" equal to whatever TextBox just got the focus.
Now when one of our KeyPad buttons is pressed, we switch back to whatever control last had the focus via our "lastControl" variable and then send the keystroke...
Make sense?
All of the keypad buttons are handled by the same cmdKeypad_Click() handler because they are ALL listed after its Handles clause:
Private Sub cmdKeypad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdKeypad0.Click, cmdKeypad1.Click, cmdKeypad2.Click, cmdKeypad3.Click, cmdKeypad4.Click, cmdKeypad5.Click, cmdKeypad6.Click, cmdKeypad7.Click, cmdKeypad8.Click, cmdKeypad9.Click
The same thing applies to the TextBox_GotFocus() sub since both textboxes are listed there after the Handles keyword.
Private Sub cmdKeypad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdKeypad0.Click, cmdKeypad1.Click, cmdKeypad2.Click, cmdKeypad3.Click, cmdKeypad4.Click, cmdKeypad5.Click, cmdKeypad6.Click, cmdKeypad7.Click, cmdKeypad8.Click, cmdKeypad9.Click
The same thing applies to the TextBox_GotFocus() sub since both textboxes are listed there after the Handles keyword.
ASKER
yeups i understand it now
thanks a bunch
thanks a bunch
ASKER
i am sort of confused as to how this code works...