' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Imports System
Module Main
    Function CountSubStr(s As String, ss As String) As Integer
            Dim res As Integer
            Dim ix As Integer
            res = 0
            ix = 0
            Do
                ix = s.indexOf(ss, ix + 1)
                If ix > 0 Then res = res + 1
            Loop Until ix <= 0
            CountSubStr = res
    End Function
    Sub Main()
        Console.WriteLine(CountSubStr("Dette er en test", "t"))
    End Sub
End Module
