by sameer sangurdekar (1 Submission)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 18th October 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Find Number Of Occurances Of A Given Substring In A Given Main String
API Declarations
'Simple Function To Find Number Of Occurances Of A Given Substring In A Main String
'Just pass 2 srtings to the given Function
'***************************************************************************
Dim LenStr, i, LenSearch, GotChar, j
LenStr = Len(searchin)
LenSearch = Len(searchfor)
i = 1
While i <= LenStr
GotChar = Mid(searchin, i, LenSearch)
If GotChar = searchfor Then
j = j + 1
i = i + LenSearch
Else
i = i + 1
End If
Wend
MsgBox "'" & searchfor & "' occures '" & CStr(j) & "' times in '" & searchin & "'"
End Function
No comments have been posted about Find Number Of Occurances Of A Given Substring In A Given Main String. Why not be the first to post a comment about Find Number Of Occurances Of A Given Substring In A Given Main String.