VB-获取某字符在其中出现的次数

 '方法1:
Dim str As String
str = ""
MsgBox(UBound(Split(str, ""))) '方法2:
Dim n&, j&
j =
n = InStr(, text1.Text, "/ITEMNAME")
While n <>
n = InStr(n + , text1.text, text2.text)
j = j +
Wend
Print(j) '方法3:
'调用 strCount(TextBox8.Text, "/ITEMNAME") Function strCount(ByVal strA As String, ByVal strB As String) As Long
Dim lngA As Long
Dim lngB As Long
Dim lngC As Long
lngA = Len(strA)
lngB = Len(strB)
lngC = Len(Replace(strA, strB, ""))
strcount = (lngA - lngC) / lngB
MsgBox(strCount) End Function
上一篇:SCOI2009游戏


下一篇:java设计原则---开闭原则