有个字符串:"01,04,01,12,13,14,04,35,67,89,01,55"我想统计,例如:"04"出现的次数,多谢懂的朋友教一下.

解决方案 »

  1.   

    dim s() as integer
    s=split(str,",")for i=0 to ubound(s)
      if s(i)="04" then iCount=iCount+1
    next i大致就这样了,你自己再看看
      

  2.   

    dim b() as string
    b=split("01,04,01,12,13,14,04,35,67,89,01,55",",")
    dim i as integer
    dim n as integer
    for i=0 to uBound(b)
     if b(i)="04" then n=n+1
    next 
    debug.print n
      

  3.   

    b=split("01,04,01,12,13,14,04,35,67,89,01,55","04")
    msgbox uBound(b)
    简单明了
      

  4.   

    b=split("01,04,01,12,13,14,04,35,67,89,01,55","04")
    msgbox uBound(b)
    简单明了==========================================================这个方法好,不过应该在改下,把"04"改成",04,"更好些。
      

  5.   

    Option ExplicitFunction SubStrCount(ByVal sData As String, ByVal sSub As String) As Long
        SubStrCount = (Len(sData) - Len(Replace(sData, sSub, ""))) \ Len(sSub)
    End FunctionPrivate Sub Form_Load()
        Debug.Print SubStrCount("01,04,01,12,13,14,04,35,67,89,01,55", "04")
        Debug.Print SubStrCount("01,04,01,12,13,14,04,35,67,89,01,55", "01")
        End
    End Sub