-
Is there a faster way to go through a string to detect if there are illegal characters? This is what I am using right now.
Thank You
Code:
Option Explicit
Sub Main()
'PURPOSE: Test Data
Dim str_Data As String
str_Data = "How are you today?"
'PURPOSE: Illegal Characters
Dim str_IllegalChar As String
str_IllegalChar = "\/:*?""<>|"
Dim str_Char As String
Dim int_X As Integer
For int_X = 1 To Len(str_Data)
str_Char = Mid(str_Data, int_X, 1)
If InStr(1, str_IllegalChar, str_Char) <> 0 Then
MsgBox str_Char
End If
Next
End Sub
-
Nope
I take it you are interested in reporting the illegal
symbol in which case your code looks as good as anything :)
Assuming you have a TextBox for data entry, then:
If there are loads other illegal chars as well, ones that
you couldn't type but could paste into your TextBox, then
you would probably be better checking for legal characters
since most likely they will be printable.
Regards