Search Tools Links Login

Count String Occurances

Count the number of string occurrences inside another string.

Public Function Count(Source As String, Countee As String) As Long
   Dim I As Long, iCount As Integer
   iCount = 0
   I = 1
      If (I > Len(Source)) Then Exit Do
      I = InStr(I, Source, Countee, vbTextCompare)
      If I Then
         iCount = iCount + 1
         I = I + 1
      End If
   Loop While I
   sCount = iCount
   Exit Function
   sCount = 0
   Exit Function
End Function

About this post

Posted: 2020-08-30
By: vb6boy
Viewed: 179 times


Visual Basic 6


No attachments for this post

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.