StrCount function
Function that counts the occurrance of a given phrase in a larger string. (I needed this function and couldn't find anything like it in MSDN for VB)
AI
AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Source Code
Public Function StrCount(ByVal cToSearch As String, ByVal cSearchPhrase As String) As Long Dim nDifference As Long ' The difference in length after the replace ' Is there anything to search? If Len(cSearchPhrase) > 0 Then nDifference = Len(cToSearch) - Len(Replace(cToSearch, cSearchPhrase, "")) StrCount = nDifference / Len(cSearchPhrase) Else StrCount = 0 End If End Function
Original Comments (3)
Recovered from Wayback Machine