Reputation: 287
Quick question, is there anyway I can modify this statement to include all special characters, i.e. !?&^%$£ etc
If tb.Text.Contains("!") Then
Score += 25
End If
I've tried
If tb.Text.Contains("!"|"?"|"*") Then
Score += 25
End If
and
If tb.Text.Contains("!","?","*") Then
Score += 25
End If
If there isn't a way I could just write them out individually but i'd prefer to have them within a few lines if possible, thanks for any help
Upvotes: 0
Views: 47
Reputation: 1981
Take a look at Regular Expressions. You can--carefully, since the "special characters" also often do things in the regular expression, which you need to escape, and I may not have caught them all--have something like
Imports System.Text.RegularExpressions
Dim m As Match = Regex.Match(tb.Text,"(!|\?|&|^|%|\$|£)")
(The pipes, in this case, show alternate things to match. Since you're looking for any of the characters, it's fairly easy except for the aforementioned caveat.)
And then check the value of m.Success
.
Upvotes: 1