enterSearchContent = Inputbox("输入搜索内容") entersearchterm = Inputbox("输入搜索词")
调用 funcSearchContentMatchCount(enterSearchContent,entersearchterm)
函数 funcSearchContentMatchCount(strsearchcontent,strsearchterm)
If Typename(enterSearchContent) = "String" Then
If len(enterSearchContent) >0 Then
strsearchcontent = Lcase(cstr(enterSearchContent))
else
msgbox "Content is blank"
End If
Else
msgbox "Not a valid string"
End If
If Typename(entersearchterm) = "String" Then
If len(entersearchterm) >0 and len(enterSearchContent)>len(entersearchterm) Then
strsearchterm = Lcase(cstr(entersearchterm))
else
msgbox "Search Term is blank or Search Term Length is greater than Search Content"
End If
Else
msgbox "Not a valid string"
End If
arrstrsearchcontent = split(strsearchcontent," ")
intsearchterm = 0
intsearchtermExactMatch = 0
For i = 0 To Ubound(arrstrsearchcontent) Step 1
If instr(arrstrsearchcontent(i),strsearchterm)<>0 Then
intsearchterm = intsearchterm+1
If strcomp(arrstrsearchcontent(i),strsearchterm,0) = 0 Then
intsearchtermExactMatch = intsearchtermExactMatch+1
End If
End If
Next
TotalMatchCount = intsearchterm
TotalExactMatchCount = intsearchtermExactMatch
Msgbox "Total Number of occurences of Search Term is "&TotalMatchCount
Msgbox "Total Number of Exact occurences of Search Term is "&TotalExactMatchCount
结束功能