Donot allow a space in a textBox

Posted by Satyapriyanayak under Windows Forms category on | Points: 40 | Views : 1151
In this Code Snippet we will know how to do not to allow a space in a textbox. code

Public Class Form1

Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = " " Then
e.Handled = True
End If
End Sub

End Class code

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
if (e.KeyChar == ' ') e.Handled = true;

Comments or Responses

Login to post response