how to do error trapping in textbox where the user cannot abuse the space bar.
for example:
i want to type hi
h i
trisha0906
10
Newbie Poster
Unhnd_Exception
commented:
Just[space][space][space]Because
-2
codeorder
commented:
just.because, w/out [space]
+12
Recommended Answers
Jump to PostHi,
Do you want to restrict the spaces in text Box?
If so use the below codePrivate Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown If e.KeyCode = Keys.Space Then e.SuppressKeyPress = True End If End Sub Private Sub TextBox1_KeyUp(ByVal sender As …
Jump to PostYou can change it after their done typing.
Use this code in the lost focus or validated event of the textbox. All excessive spaces will be removed.
Private Sub TextBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.LostFocus TextBox1.Text = String.Join(" ", TextBox1.Text.Split(New Char() {" …
All 8 Replies
kothaisaravan
0
Light Poster
Begginnerdev
256
Junior Poster
trisha0906
10
Newbie Poster
adam_k
239
Master Poster
trisha0906
10
Newbie Poster
Unhnd_Exception
trisha0906
10
Newbie Poster
trisha0906
10
Newbie 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.