|
-
Dec 4th, 2000, 05:46 PM
#1
Thread Starter
PowerPoster
Here's my dilema. I find myself always running into problems when using the KeyPress, KeyDown, KeyCode, KeyUp..Can anyone tell me when to use one over the other?? Little confused on this subject. Thanks
-
Dec 4th, 2000, 05:55 PM
#2
Hyperactive Member
Try and do everything in the Validate instead of the Key... events. If you must use the Key... events, use KeyPress if you don't care about modifier keys (alt, shift, ctrl) - otherwise, use the KeyDown.
Some people use the change event instead. If you do, be careful about modifying the text in the textbox, because that will fire off another change event.
-
Dec 4th, 2000, 06:02 PM
#3
Frenzied Member
One thing for sure, if you want to Cancel a users input, you should use KeyPress, because you can set the KeyAScii to 0:
Code:
Sub Text1_Keypress(KeyAscii As Integer)
If Keyascii = vbKeyA then KeyAscii = 0 'if the user types a, eat it and don't let it to the textbox :)
end Sub
You can use the KeyDown & KeyUp to notice if someone's holding the keys.
Code:
Private holding As Boolean
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
holding = True
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
If holding Then MsgBox "you held the button for and released it :)"
holding = False
End Sub
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Dec 4th, 2000, 07:40 PM
#4
Thread Starter
PowerPoster
.
Thank you for setting me straight
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
|