A CountChar - Better than looping through a string!!!
It used to be, when I wanted to count the number of times a charector appeared in a string, I would loop through the string letter by letter and keep a count. I have replace my old methodolgies with this one, which also allows you to search for substrings (more than 1-digit long)
Original Author: [])utch[]v[]aster
Code
Public Function CountChar(vText as String, vChar as String, Optional IgnoreCase as Boolean) as Integer
If IgnoreCase Then
vText = LCase$(vText)
vChar = LCase$(vChar)
End If
Dim L as Integer
L = Len(vText)
vText = Replace$(vText, vChar, "")
CountChar = (L - Len(vText)) / Len(vChar)
End Function
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.