CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: textbox

  1. #1
    Join Date
    Sep 2004


    How to make the textbox can't enter Special Character (! @ # $ % ^) ?
    anyone noe?
    thx for helpin

  2. #2
    Join Date
    Oct 2004

    Re: textbox

    Not sure what your asking.

    txtbox1.text = "! @ # $ % ^" ?

  3. #3
    Join Date
    Oct 2004

    Re: textbox

    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")
    End If

  4. #4
    Join Date
    Sep 2004

    Re: textbox

    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

  5. #5
    Join Date
    Feb 2000
    OH - USA

    Re: textbox

    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
        End Sub
    Good Luck,
    Craig - CRG IT Solutions - Microsoft Gold Partner

    -My posts after 08/2015 = .NET 4.x and Visual Studio 2015
    -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 all threads, so if you have a secondary question, message me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.