第一种方法:
Dim iCount, iFound
iCount = 0
iFound = 0
iFound = inStr(iFound + 1, mainStr, subStr)
While iFound <> 0
iCount = iCount + 1
iFound = InStr(iFound + 1, mainStr, subStr)
Wend
第二种方法:
iCount = UBound(Split(mainStr, subStr))
第三种方法:
iCount = (Len(mainStr) - Len(Replace(mainStr, subStr, ""))) / Len(subStr)