October 26th, 2004, 11:16 AM
How to make the textbox can't enter Special Character (! @ # $ % ^) ?
thx for helpin
October 26th, 2004, 11:21 AM
Not sure what your asking.
txtbox1.text = "! @ # $ % ^" ?
October 26th, 2004, 02:54 PM
You may want to try something with the text box's "validating" event.
Just keep in mind that the validating event is triggered by another control that has its "CausesValidation" property set to True.
For instance, if you wanted to make sure only numbers were entered in a textbox called "txtQuantity" you would do the following inside the validating event sub...
If Not IsNumeric(txtQuantity.Text) Then
MessageBox.Show("Must be a number")
November 3rd, 2004, 07:39 AM
i mean tat i just want the textbox accept text (A-Z) only.
like in Access, u set the input mask to ">L<????????" rite, then u can only input text. Symbol and Number is not allow. That is wat i want in my Vb.NET
November 3rd, 2004, 08:07 AM
Regular Expressions are the easiest way to do this:
Private _ExpressionToMatch As New System.Text.RegularExpressions.Regex("[a-zA-Z]")
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Not _ExpressionToMatch.IsMatch(e.KeyChar) Then _
e.Handled = True
- CRG IT Solutions
- Microsoft Gold Partner
-My posts after 11/2011 = .NET 4.x and Visual Studio 2012
-My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
-My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
-My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
-My posts before 04/2007 = .NET 1.1/2.0
*I do not follow threads, so if you have a secondary question, message me.
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!