Check String if it has an ascii like "/" and ":" using VBA

vba

Solution

Change your code to this:

Function HasCharacter(strData As String) As Boolean

     If InStr(strData, "/") > 0 Or InStr(strData, ":") > 0 Then
       HasCharacter = True
     Else
       HasCharacter = False
     End If
End Function

The function `InStr` returns the position of the string if found, else it returns 0.

Problem

Here's my code but i want to know how will I know if the string has special characters like '/' or ':'.Many Thanks. Much great if you can edit my function. ``` Do Until EOF(1) Line Input #1, LineFromFile <-----LineFromFile is the string If HasCharacter(LineFromFile) = True Then MsgBox "This File should be uploaded to FilePath2" Else Blah Blah Blah....... ``` This is my function ``` Function HasCharacter(strData As String) As Boolean Dim iCounter As Integer For iCounter = 1 To Len(strData) If ....(Don't know what to say) Then HasCharacter = True Exit Function End If Next iCounter End Function ```

Original source