README.md

December 5, 2022 ยท View on GitHub

Character counter

Description

A FAST and EASY way to count the number of occurrences of one string within another! Please vote for this tip if you find it useful.

More Info

Submitted On
ByChris Wilson
LevelAdvanced
User Rating4.5 (18 globes from 4 users)
CompatibilityVB 6.0
CategoryString Manipulation
WorldVisual Basic
Archive File

Source Code

Private Sub Test()
Const mystr = "This is a test of the split function"
' returns 6
Debug.Print Occurs(mystr, "t")
End Sub
Public Function Occurs(ByVal strtochk As String, ByVal searchstr As String) As Long
' remember SPLIT returns a zero-based array
Occurs = UBound(Split(strtochk, searchstr)) + 1
End Function