Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function count(ByVal haystack As String, ByVal needle As String) As Integer
- Dim start As Integer = 1 'number of charactors in, in which to start searching from (stops counting the same one)
- Dim total As Integer = 0 'the total number of occurences
- 'Count until there are no more
- Do Until InStr(start, haystack, needle) = 0
- start = InStr(start, haystack, needle) + 1
- total = total + 1
- Loop
- 'return the value
- Return total
- End Function
Advertisement
Add Comment
Please, Sign In to add comment