a = "AAAbbbbAAAA"
print func(a,"A") => 7

解决方案 »

  1.   

    function func(str1 as string,str2 as string) as long
        dim i as long
        func=0
        for i=1 to len(str2)
            if str1=mid(str2,i,1) then func=func+1
        next
    end function
      

  2.   

    Private Sub Command2_Click()
    Dim ls_Content() As String
    Dim LogCount As Long
    Dim a As Stringa = "AAAbbbbAAAA"
    ls_Content = Split(a, "A")'查找的字符串
    LogCount = UBound(ls_Content, 1)
    MsgBox LogCount'得到A的个数
    End Sub
      

  3.   

    Function getCount(ByVal str As String, countstr As String) As Integer
        getCount = (Len(str) - Len(Replace(str, countstr, ""))) / Len(countstr)
    End Function
    str是字符串,countstr是计算重复出现的字符串。
      

  4.   

    使用范例:Private Sub Command1_Click()
        Dim a As String
        
        s = "12123dlkdfjsdfjoidj123skjdisduirenjds123"
        Debug.Print getCount(s, "123")
    End Sub
      

  5.   


    Option Base 1
    Private Sub Command1_Click()
    MsgBox UBound(Split("AAAbbbbAAAA", "A", , vbBinaryCompare))
    End Sub
      

  6.   

    cpio
    你的解决方法太有创意了
    goood!
    佩服!
      

  7.   

    TechnoFantasy(冰儿马甲www.applevb.com)
    方法太牛了~佩服的没话说!