P pekt2s Member Joined Apr 26, 2007 Messages 15 Programming Experience Beginner Apr 26, 2007 #1 Help me pls. What will i do if i want the textbox accept only numbers or Letters? can you give sample codes? pls...
Help me pls. What will i do if i want the textbox accept only numbers or Letters? can you give sample codes? pls...
S Solitaire Well-known member Joined Jun 28, 2004 Messages 465 Location New York Programming Experience 10+ Apr 26, 2007 #2 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: Apr 26, 2007 Upvote 0 Downvote
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