What is the syntax to count how many times a substring occurs in a string?

<integer variable> = Len(<string>) - Len(Replace(<string>, "<substring>", "")) 
'example
sentence = "Hello, this is a sentence,"
countCommas = Len(sentence) - Len(Replace(sentence, ",", "")) 
msgbox(countCommas) 'output is 2
Advertisements