Last active
November 30, 2017 07:50
-
-
Save KirillPashkov/892df37d574624ca66f79c9d58fe575b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Find = chr(34) | |
Str = "This is string with " & chr(34) & "double quotes" & chr(34) & "." | |
Occurrences = (Len(Str) - Len(Replace(Str,Find,Empty)) / Len(Find)) | |
MsgBox "String: " & Str & vbCrLf &_ | |
"Contains :" & Occurrences & " occurrences of: " & Find & "." | |
Function GetOccurrences(InputString,LookupString) | |
If _ | |
IsNull(InputString) Or IsEmpty(InputString) Or _ | |
IsNull(LookupString) Or IsEmpty(LookupString) _ | |
Then | |
GetOccurrences = 0 | |
Else | |
If Len(InputString) = 0 Or Len(LookupString) = 0 Then | |
GetOccurrences = 0 | |
Else | |
GetOccurrences = (Len(InputString) - Len(Replace(InputString,LookupString,Empty)) / Len(LookupString)) | |
End If | |
End If | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment