How do i avoid the entry of Numbers in a textbox?
nIcks123
0
Newbie Poster
Recommended Answers
Jump to PostUse the following handler
Private Sub TextBox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If Char.IsDigit(e.KeyChar) Then e.Handled = True End If End Sub
Jump to Postinside your textbox code go to the keypress event and paste the code of reverend jim... ^_^
Jump to Postbrylle - exactly how does your code accomplish what was asked? In English it becomes
If char is not a digit Then ignore this keypress End If If char is backspace Then don't ignore this keypress End If
What you have posted does the complete opposite …
All 11 Replies
Reverend Jim
4,780
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
poojavb
29
Junior Poster
Reverend Jim
commented:
does the opposite of what was asked
-2
ome2012
2
Junior Poster in Training
poojavb
29
Junior Poster
Reverend Jim
commented:
unnecessarily complicated and has redundant code
+0
TnTinMN
418
Practically a Master Poster
Reverend Jim
4,780
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
brylle
-2
Junior Poster in Training
Reverend Jim
commented:
does the opposite of what was asked
-2
Reverend Jim
4,780
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
Reverend Jim
4,780
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
nmaillet
97
Posting Whiz in Training
Reverend Jim
4,780
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.