RomeoJuliet
Registered User.
- Local time
- Today, 13:10
- Joined
- Nov 20, 2008
- Messages
- 23
I am writing a POS application and need to make an on-screen keypad more efficient. I want to allow the user to 'click' each of the number buttons by pressing an actual number key on the keyboard, as well as by clicking the button controls.
I have changed KeyPreview to Yes in the form's properties, and written this code for the On Keypress event:
Unfortunately, nothing happens: the focus doesn't change as I press different number keys, and no event appears to take place.
Can anyone help?
Many thanks
Mike.
I have changed KeyPreview to Yes in the form's properties, and written this code for the On Keypress event:
Code:
Private Sub Form_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case vbKey1 Or vbKeyNumpad1
Me.Command0.SetFocus '1 control on form
SendKeys "{enter}"
Case vbKey2 Or vbKeyNumpad2
Me.Command1.SetFocus '2 control on form
SendKeys "{enter}"
Case vbKey3 Or vbKeyNumpad3
Me.Command2.SetFocus '3 control on form
SendKeys "{enter}"
Case vbKey4 Or vbKeyNumpad4
Me.Command3.SetFocus '4 control on form
SendKeys "{enter}"
Case vbKey5 Or vbKeyNumpad5
Me.Command4.SetFocus '5 control on form
SendKeys "{enter}"
Case vbKey6 Or vbKeyNumpad6
Me.Command5.SetFocus '6 control on form
SendKeys "{enter}"
Case vbKey7 Or vbKeyNumpad7
Me.Command6.SetFocus '7 control on form
SendKeys "{enter}"
Case vbKey8 Or vbKeyNumpad8
Me.Command7.SetFocus '8 control on form
SendKeys "{enter}"
Case vbKey9 Or vbKeyNumpad9
Me.Command8.SetFocus '9 control on form
SendKeys "{enter}"
Case vbKey0 Or vbKeyNumpad0
Me.Command9.SetFocus '0 control on form
SendKeys "{enter}"
End Select
End Sub
Can anyone help?
Many thanks
Mike.