Keyup - Page 2 - Techist - Tech Forum

Go Back   Techist - Tech Forum > Computer Software > Programming
Click Here to Login
Closed Thread
 
Thread Tools Display Modes
 
Old 10-23-2003, 12:11 AM   #11 (permalink)
Newb Techie
 
Join Date: May 2003
Posts: 15
Send a message via AIM to rwp2Lehigh
Default

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?
__________________

__________________
rwp2Lehigh is offline  
Old 10-23-2003, 06:38 AM   #12 (permalink)
Newb Techie
 
Join Date: Oct 2003
Posts: 9
Send a message via Yahoo to skbandi
Default

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
__________________

__________________
skbandi is offline  
Old 10-24-2003, 10:23 AM   #13 (permalink)
Newb Techie
 
Join Date: May 2003
Posts: 15
Send a message via AIM to rwp2Lehigh
Default

Thats not working either....grrrrrrrrrrrrrrrrrrrrrrrrrrrrr
__________________
rwp2Lehigh is offline  
Old 10-25-2003, 02:52 AM   #14 (permalink)
Newb Techie
 
Join Date: Oct 2003
Posts: 9
Send a message via Yahoo to skbandi
Default

send me ur full project as zip to my mail id including the form along with the code.
__________________
skbandi is offline  
Old 10-25-2003, 08:47 AM   #15 (permalink)
Banned
 
Join Date: May 2003
Posts: 105
Default

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
__________________
_Jack is offline  
Old 10-25-2003, 11:43 AM   #16 (permalink)
Newb Techie
 
Join Date: May 2003
Posts: 15
Send a message via AIM to rwp2Lehigh
Default

Whats ur e-mail skbandi? I really appreciate the help...
__________________
rwp2Lehigh is offline  
Old 10-25-2003, 10:57 PM   #17 (permalink)
Newb Techie
 
Join Date: Oct 2003
Posts: 9
Send a message via Yahoo to skbandi
Default

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
__________________

__________________
skbandi is offline  
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Copyright 2002- Social Knowledge, LLC All Rights Reserved.

All times are GMT -5. The time now is 01:13 PM.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2018, vBulletin Solutions, Inc.