【QTP】检查身份证号是否正确

网上看到的一段检查身份证号是否正确的脚本:

'检查身份证号是否正确
Function Identification(Text1)
    xian = Text1
    If (Not IsNumeric(Left(Text1, 15)) And Not IsNumeric(Left(Text1, 18))) Or Text1 = "" Then
        Identification = False
        Exit Function
    End If
    lenx = Len(Trim(Text1))
    If lenx = 15 Or lenx = 18 Then
        If lenx = 15 Then
            yy = "19" & Mid(xian, 7, 2)
            mm = Mid(xian, 9, 2)
            dd = Mid(xian, 11, 2)
            aa = Right(xian, 1)
        End If
        If lenx = 18 Then
            yy = Mid(xian, 7, 4)
            mm = Mid(xian, 11, 2)
            dd = Mid(xian, 13, 2)
            aa = Right(xian, 1)
        End If
        If CInt(mm) > 12 Or CInt(dd) > 31 Then
            Identification = False
            Exit Function
        Else
            Identification = True
            Exit Function
        End If
    Else
        Identification = False
        Exit Function
    End If
End Function

发表评论

电子邮件地址不会被公开。

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据