Keyup

Status
Not open for further replies.
Ok,

I tried what you said, but I can't get it working. I'm going to post the relevant part of the code and maybe you can see the mistake from it. I really appreciate all the help everyone...

Private Sub frmCalc_load()
frmCalc.KeyPreview = True
frmCalc.SetFocus
End Sub

Private Sub frmCalc_Keyup(Keycode As Integer, Shift As Integer)
MsgBox ("Key was pressed")
Select Case Keycode
Case Asc("0")
Call btn0_Click
Case Asc("1")
Call btn1_Click
Case Asc("2")
Call btn2_Click
End Select
End Sub

Any ideas?
 
there is no problem with the code exept for that form load event cannot have form setfocus method.
the problem is whether u r using the numeric keypad numbers or the numbers on the top of the keyboard, as the ascii codes for them differ (example : '1' on upper keyboard has ascii code of 47 whwreas that for the numeric keypad one is 96.
try this
select case keycode
case vbkey0
*****ur code
case vbkeynumpad0
*****ur code
 
Create a new project with a single form, on this form put 10 buttons all called btn with the index and caption properties set to the numeric value of the key (0-9). Also on this form put a label control called lblDisplay.
On the properties of the form set the keypreview property to true.

Then paste the following code:
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
' MsgBox ("Key was pressed")
Select Case KeyCode
Case Asc("0"), 96
Call btn_Click(0)
Case Asc("1"), 97
Call btn_Click(1)
Case Asc("2"), 98
Call btn_Click(2)
Case Asc("3"), 99
Call btn_Click(3)
Case Asc("4"), 100
Call btn_Click(4)
Case Asc("5"), 101
Call btn_Click(5)
Case Asc("6"), 102
Call btn_Click(6)
Case Asc("7"), 103
Call btn_Click(7)
Case Asc("8"), 104
Call btn_Click(8)
Case Asc("9"), 105
Call btn_Click(9)

End Select
End Sub

Private Sub btn_Click(Index As Integer)
lblDisplay.Caption = Index
End Sub
 
skbandi@rediffmail.com
i had checked ur code. there is absolutely no problem with it. its working fine. but now what do u wanted to accomplish with that code. it displays the number whenevr u press the corresponding key., but if u want to show all the key presses before any operator key is pressed for ex , addition or subtaction, then concatenate the output like
lblDisplay.caption=lblDisplay.caption+index
 
Status
Not open for further replies.
Back
Top Bottom