牛骨文教育服务平台(让学习变的简单)
博文笔记

字符判断

创建时间:2009-04-24 投稿人: 浏览次数:312


Public Function IsNumeric(Str As Variant) As Boolean
    " NULL
    If Information.IsNull(Str) Then
        IsNumeric = False
        Exit Function
    End If
    
    " EMPTY
    If Information.IsEmpty(Str) Then
        IsNumeric = False
        Exit Function
    End If
    
    "
    If Not Information.IsNumeric(Str) Then
        IsNumeric = False
        Exit Function
    End If
    
    Dim iLen As Integer
    iLen = Strings.Len(Str)
    
    " 半角
    If iLen <> Strings.Len(Strings.Trim(Str)) Then
        IsNumeric = False
        Exit Function
    End If
    
    " 全角
    If iLen <> Strings.LenB(Strings.StrConv(Str, vbFromUnicode)) Then
        IsNumeric = False
        Exit Function
    End If
    
    IsNumeric = True
    Exit Function
    
End Function

声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。