Code snippet below will check for letters and numbers on the
string.
Sub
check_for_special_char()
Dim regexItem
As Regex = New Regex("^[a-zA-Z0-9 ]*$")
Dim xval_regex
As Boolean
xval_regex =
regexItem.IsMatch(TextBox1.Text)
' MsgBox(xval_regex)
If xval_regex
= "False" Then
MsgBox("No special characters/symbols allowed.")
else
MsgBox("No special characters found on
the string")
End If
End Sub
To bypass or include some other characters such as
"-" dash sign or the ampersand "&" use the code below.
Sub
check_for_special_char()
Dim regexItem
As Regex = New Regex("^[a-zA-Z0-9\-& ]*$")
Dim xval_regex
As Boolean
xval_regex =
regexItem.IsMatch(TextBox1.Text)
' MsgBox(xval_regex)
If xval_regex
= "False" Then
MsgBox("No special characters/symbols allowed.")
else
MsgBox("No special characters found on the string")
End If
End Sub
[a-zA-Z0-9\-& ] --- Regex to check for small and capital
letters, numbers, dash sign and ampersand.
The dash sign is preceded with the back slash that tells
regex to interpret the character literally and search for the character.
To use regex in VB.Net you need to declare this import,
Imports System.Text.RegularExpressions
Cheers.. Have fun...
===============
http://quickbytesstuff.blogspot.sg/2014/09/how-to-recite-rosary.html
===============
Catholic Rosary Guide for Android:
Pray the Rosary every day, countless blessings will be showered upon your life if you recite the Rosary faithfully.
https://play.google.com/store/apps/details?id=com.myrosaryapp
https://play.google.com/store/apps/details?id=com.myrosaryapp
thanks bro, saved me a lot of time
ReplyDeleteThanks for dropping by, and letting us know you find it helpful
Delete