Nullify keystroke in textbox

blabore

Well-known member
Joined
Jan 31, 2002
Messages
48
Location
Austin, TX
Is there any way to cancel a keystroke in a textbox in the KeyUp/KeyDown/KeyPress events? In VB 6 you could set KeyAscii to 0, which would prevent the key from showing up in the textbox. Any help would be appreciated.
 
Er yes... use the same way I just said. It works in all three.
 
Hmmm... e.Handled doesnt seem to effect the keystroke in the KeyUp or KeyDown events. Do I need to set some other properties?
 
e.Handled doesnt do anything in a textboxs keyup / keydown ( well atleast not on quite a lot of key presses , you can handle / divert stuff though on them events , like moving focus or triggering something else.
 
Well, KeyPress is the sub that does the "typing" of characters in a TextBox or whatever; KeyUp and KeyDown fire when you press a key (no matter what happens to the text in the textbox). You need to use KeyPress to handle the typing of text and KeyUp/Down to handle the pressing of keys in general (be it F12 or Control-H).
 
Back
Top