|
-
February 26th, 2003, 02:13 AM
#1
keypress event for command button is not working for "Enter" key why?
The code which i write below is not working i didn't get why?
keypress event for command button is not working for "Enter" key why?
please reply
Private Sub Command1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
MsgBox "HI"
End If
End Sub
-
February 26th, 2003, 02:22 AM
#2
i tried it .. yes it does not work
to detect enter the Click() event is fired when you press enter
-
February 26th, 2003, 03:38 AM
#3
i know it work with click() but why not with "key press "
reply
-
February 26th, 2003, 03:53 AM
#4
Return is not a "normal key", and does not call a "KeyPress" message. Neither it does Ctrl, Bloq Mays...
Caronte
Si tiene solución... ¿por qué te preocupas?
Si no tiene solución... ¿por qué te preocupas?
-
February 26th, 2003, 08:51 AM
#5
Not sure of the reason(s) why [perhaps the gurus here can tell you], but the following code works in the KeyPress event:
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Label1 = "13"
Label3.Caption = "Enter key."
End If
End Sub
If kids were left to their own devices, would they ever come up with a thing like war?......The Wheel / Todd Rundgren
Do canibals not eat clowns because they taste funny? 
-
February 26th, 2003, 08:54 AM
#6
Doof,
What you're testing against is the scancode of the key pressed whereas Sa is testing against a VB character.
-
February 26th, 2003, 09:00 AM
#7
MOwen.... of what you say I am well aware.
Happened to notice that one works and one does not.
I just don't know the reason(s) why.
If kids were left to their own devices, would they ever come up with a thing like war?......The Wheel / Todd Rundgren
Do canibals not eat clowns because they taste funny? 
-
February 26th, 2003, 09:16 AM
#8
Oooops ..............my appologies. Just noticed I was testing the wrong thing. Please excuse my error.
If kids were left to their own devices, would they ever come up with a thing like war?......The Wheel / Todd Rundgren
Do canibals not eat clowns because they taste funny? 
-
February 27th, 2003, 03:09 PM
#9
I have the same problem a long time ago but I found out that if you use KeyUp or KeyDown, it will work properly. That what I use it most applications I develop here.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|