Textbox filter input

pekt2s

Member
Joined
Apr 26, 2007
Messages
15
Programming Experience
Beginner
Help me pls. What will i do if i want the textbox accept only numbers or Letters? can you give sample codes? pls...
 
Place this code in the KeyPress event of the textbox to allow only numeric digits:

If Not IsNumeric(e.KeyChar) Then e.Handled = True


To allow only letters:

If Not Char.IsLetter(e.KeyChar) Then e.Handled = True



To allow the Backspace and Enter keys, add the following:

If e.KeyChar = Chr(8) Or e.KeyChar = Chr(13) Then e.Handled = False
 
Last edited:
Back
Top