Count The Number of Substrings Within A String

This sample code will tell you that the string 'is' appear 2 times in the string 'this is my string'.
This code use the function 'split' that available only in Visual Basic 6.0 and above.

Form Code

Private Sub Form_Load()
    myString = "this is my string"
    tempString = Split(myString, "is")
    MsgBox "'is' appears in '" & myString & "' " & UBound(tempString) & " times."
End Sub

Go Back