'''
'''  FF_TALLY
'''  字符串在字符串中的出现次数进行计数。
'''
'''  MainString is the string expression in which to count characters.  
'''  MatchPattern is the string expression to count all occurrences of. 
'''  If MatchPattern is not present in MainString, zero Is returned. 
'''  When a match is found, the scan for the next match begins at the 
'''  position immediately following the prior match.
'''  This function is case-sensitive. 
'''
'  Function FF_Tally( ByRef sMainString   as String, _
'                     ByRef sMatchPattern as String _
'                     ) as Integer

''
''  FF_TALLY
''  Count the number of occurrences of strings within a string.
''
''  MainString is the string expression in which to count characters.  
''  MatchPattern is the string expression to count all occurrences of. 
''  If MatchPattern is not present in MainString, zero Is returned. 
''  When a match is found, the scan for the next match begins at the 
''  position immediately following the prior match.
''  This function is case-sensitive. 
''
Function FF_Tally( ByRef sMainString   as String, _
                   ByRef sMatchPattern as String _
                   ) as Integer

    Dim count as Integer
    Dim i     as Integer 
   
    count = 0
    i = 1
    Do
        i = InStr(i, sMainString, sMatchPattern)
        If i > 0 Then count += 1: i += Len(sMatchPattern)
    Loop Until i = 0
   
    Return count

End Function


