VB6.0-"Change KeyAscii in KeyPress" in VB.net

Gagel

Newcomer
Joined
Jan 20, 2003
Messages
1
Location
Frankfurt, Germany
In VB 6.0 I used the KeyPress-Event to change user inputs.

E.g. when a textbox has the text "31.0" and the user hits the "2"-key, I changed the KeyAscii paramter to 0, because there is no 31th day in February.

E.g. when I didnt want that the user is able to type in german letter (like ä, ö , ü). I just changed the KeyAscii to 0.

In VB.net I am not able to change the e.Keycode paramter and in the KeyPress events the changes are already made. I think that I have to use the KeyDown method, but how can I change the Keycode?
 
Last edited:
You can use the Keypress to limit the input or compare the input...
Visual Basic:
If Not e.KeyChar.(more methods here) Then

you can also use the Validating event, and if you don't want to accept the input, you can...
Visual Basic:
e.Cancel = True
 
Back
Top