没有现成的,要自己编写。
private function GetCount(byval s as string,byval k as string) as long
dim i as long
dim Count as string
do
i=instr(s,k,i+1)
if i=0 then exit do
Count=Count+1
loop until i=0
getCount=Count
end function
private function GetCount(byval s as string,byval k as string) as long
dim i as long
dim Count as string
do
i=instr(s,k,i+1)
if i=0 then exit do
Count=Count+1
loop until i=0
getCount=Count
end function
函数为InStr()
请再看一看msdn
'StrInfo 总字符
'StrTemp字符串
'BlnRepeat是否允许字符重复使用:如为真,aaa里面包含2个aa,否则包含一个aa
Dim CurrentPosition As Long
Dim NextPosition As Long
If StrInfo <> """" And StrTemp <> """" And Len(StrInfo) > Len(StrTemp) Then
If BlnRepeat = False Then '不允许重复
StrNumber = (Len(StrInfo) - Len(Replace(StrInfo, StrTemp, """"))) / Len(StrTemp)
Else
Do
CurrentPosition = NextPosition
NextPosition = InStr(CurrentPosition + 1, StrInfo, StrTemp)
If NextPosition > 0 Then
StrNumber = StrNumber + 1
End If
Loop Until NextPosition = 0
End If
End If
End Function