如何判断一串字符串全是由数字组成的

解决方案 »

  1.   

    aa="123456"
    if isnumeric(aa) then
        msgbox "全为数字"
    else
        msgbox "有非数字"
    end if
      

  2.   

    IsNumeric("2e3") 返回 Truedim s as string
    dim sPattern as strings = "38976"
    sPattern = String$(Len(s), "#")
    Debug.Print IIf(s Like sPattern, "全数字", "非数字")
      

  3.   

    IsNumeric还不够,如果是一个很大的数字那就没用了,还是老老实实循环一次,这样的小问题也用不着正则了
      

  4.   

    Dim reg As Object
    Set reg = CreateObject("vbscript.regexp")
    reg.Pattern = "^\d+$"
    MsgBox reg.test("123")