For Numeric Textbox, Alphabetic Textbox N Regular Expression Symbol
For Numeric Textbox, Alphabetic Textbox N Regular Expression Symbol
Private Sub txtfindWhat_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtfindWhat.TextChanged Dim sText As String Dim cInvalidChars() As Char = {"~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "-", "=", "+", "{", "[", "}", "]", "|", "\", ":", ";", """", "'", "<", ",", ">", ".", "?", "/"} Dim iIndex As Integer sText = txtfindWhat.Text iIndex = sText.IndexOfAny(cInvalidChars) 'All valid chars If (iIndex = -1) Then Return 'Remove invalid char txtfindWhat.Text = sText.Remove(iIndex, 1) 'Put the cursor back on the last pos txtfindWhat.SelectionStart = txtfindWhat.Text.Length End Sub
$ | [] [^]
dollar sign pipe square brackets carat enclosed in square brackets parentheses exclamation point question mark asterisk plus n enclosed in braces n, enclosed in braces ,n enclosed in braces n,m enclosed in braces
Match the end of the line, as in A$. Match either the regular expression preceding it or the regular expression following it. Match any single character from within the bracketed list, as in [abcde]. Use a hyphen (-) for a range, as in [0-9]. Within square brackets, most characters are interpreted literally. Match any single character except those within the bracketed list, as in [^0-9]. Group one or more regular expressions to establish a logical regular expression consisting of sub-regular expressions. Used to override the standard precedence of specific operators. Do not match the next character or regular expression. Match 0 or 1 time. Match 0 or more times. Match 1 or more times. Match exactly n times. Match n or more times. Match n or fewer times. Match at least n times but not more than m times.
2. If (Microsoft.VisualBasic.Asc(e.KeyChar) < 65) _ 3. Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 90) _ 4. And (Microsoft.VisualBasic.Asc(e.KeyChar) < 97) _ 5. Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 122) Then 6. 'space accepted 7. If (Microsoft.VisualBasic.Asc(e.KeyChar) <> 32) Then 8. e.Handled = True 9. End If 10. End If 11. If (Microsoft.VisualBasic.Asc(e.KeyChar) = 8) Then 12. 13. e.Handled = False 14. End If 15. End Sub