special characters
Dear experts,
I am working on a userform where I have a textbox - the
user should input a name, and as this is used afterwards
to name a file, it should not contain any "Special"
characters (like \, /, etc).
Now, I have written some code to try and spot when the
user inputs such characters, but 1) I have a problem with
the " character (Excel does not accept textbox.value = """
and not even Msgbox = "|</"?*\" )and 2)I am pretty sure
there must be a simpler way to do this!
Here is my code:
For i = 1 To Len((TextBox33.Value))
If Mid(TextBox33.Value, i, 1) = "\" _
Or Mid(TextBox33.Value, i, 1) = "|" _
Or Mid(TextBox33.Value, i, 1) = "/" _
Or Mid(TextBox33.Value, i, 1) = "*" _
Or Mid(TextBox33.Value, i, 1) = "?" _
Or Mid(TextBox33.Value, i, 1) = "<" _
Or Mid(TextBox33.Value, i, 1) = "" _
Or Mid(TextBox33.Value, i, 1) = ":" Then
MsgBox "The product name cannot contain any of the
following characters:" & vbNewLine & "\/:*?<|"
Exit Sub
End If
Next i
Can you please help me?
Many thanks in advance!
Best regards,
Valeria
|