I'm trying to create a form that has a text box that only accepts text entries (i.e. no numeric entries). I can't figure it out....this is what I have so far...

Private Sub textName_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles textName.TextChanged
        If textName.Text.Trim <> "" Then
            Try
                employeeName = Text
            Catch ex As Exception
                MessageBox.Show("Input Must Be Text Only", _
                     "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                textName.Focus()
                textName.SelectAll()
            End Try
        End If
    End Sub
End Class

Maybe look into regular expressions. Example:

Sub Main()

        Dim rgx As New System.Text.RegularExpressions.Regex("^[a-zA-Z]+$")
        Console.WriteLine(rgx.IsMatch("ABC"))
        Console.WriteLine(rgx.IsMatch("A12"))
        Console.Read()


    End Sub
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.