I have a string (for example: \"Hello there. My name is John. I work very hard. Hello there!\") and I am trying to find the number of occurrences of the string
Dim input As String = "Hello there. My name is John. I work very hard. Hello there!"
Dim phrase As String = "Hello there"
Dim Occurrences As Integer = (input.Length - input.Replace(phrase, String.Empty).Length) / phrase.Length
You just need to make sure that phrase.Length > 0.