验证身份证

/******************************************************************************/ //函数名: gf_CIDCheck //功能说明:验证身份证 //输入参数:1、as_strid  输入的身份证号码 //返回值: 0=正常;1=失败 //函数完成:woods /******************************************************************************/ integer  wi[1 to 18]={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1} //校验码

//判断身份证是15或18位 If Len(strId) = 15 Then  If Not isNumber(strid) Then    messagebox("提示","身份证号码输入有误!有非数字出现!" )    return 1  End If  If integer(Mid(strid, 9, 2)) < 1 Or integer(Mid(strid, 9, 2)) > 12 Then    messagebox("提示","身份证号码输入有误!月份不正确!" )    return 1  End If  If integer(Mid(strid, 11, 2)) < 1 Or integer(Mid(strid, 11, 2)) > 31 Then    messagebox("提示","身份证号码输入有误!日期不正确!" )    return 1  Else    If (integer(Mid(strid, 9, 2)) = 4 Or integer(Mid(strid, 9, 2)) = 6 Or integer(Mid(strid, 9, 2)) = 9 Or integer(Mid(strid, 9, 2)) = 11) And integer(Mid(strid, 11, 2)) = 31 Then      messagebox("提示","身份证号码输入有误!月份和日期不匹配!" )      return 1    ElseIf integer(Mid(strid, 9, 2)) = 2 And (integer(Mid(strid, 11, 2)) = 30 Or integer(Mid(strid, 11, 2)) = 31) Then      messagebox("提示","身份证号码输入有误!2月份没有" + (Mid(strid, 11, 2)) + "天!" )      return 1    End If  End If ElseIf Len(strId) = 18 Then  string  StrID17,A18  integer  AiWi, num    If Not isNumber(Left(strid, 17)) Then    messagebox("提示","身份证号码输入有误!" )    return 1  End If  If integer(Mid(strid, 11, 2)) < 1 Or integer(Mid(strid, 11, 2)) > 12 Then      messagebox("提示","身份证号码输入有误!月份不正确!" )    return 1  End If  If integer(Mid(strid, 13, 2)) < 1 Or integer(Mid(strid, 13, 2)) > 31 Then    messagebox("提示","身份证号码输入有误!日期不正确!" )    return 1  Else    If (integer(Mid(strid, 11, 2)) = 4 Or integer(Mid(strid, 11, 2)) = 6 Or integer(Mid(strid, 11, 2)) = 9 Or integer(Mid(strid, 11, 2)) = 11) And integer(Mid(strid, 13, 2)) = 31 Then      messagebox("提示","身份证号码输入有误!月份和日期不匹配!" )      return 1    ElseIf integer(Mid(strid, 11, 2)) = 2 And (integer(Mid(strid, 13, 2)) = 30 Or integer(Mid(strid, 13, 2)) = 31) Then      messagebox("提示","身份证号码输入有误!2月份没有" + (Mid(strid, 13, 2)) + "天!" )      return 1    End If  End If  StrID17 = Left(strid, 17)  AiWi = 0  For num = 1 To 17    AiWi = AiWi + integer(Mid(StrID17, num, 1)) * Wi[num]  Next  choose Case Mod(AiWi,11 )    Case 0      A18 = "1"    Case 1      A18 = "0"    Case 2      A18 = "X"    Case 3      A18 = "9"    Case 4      A18 = "8"    Case 5      A18 = "7"    Case 6      A18 = "6"    Case 7      A18 = "5"    Case 8      A18 = "4"    Case 9      A18 = "3"    Case 10      A18 = "2"  End choose  If A18 <> Right(strid, 1) Then    messagebox("提示","身份证号码输入有误!尾数校验码不正确!")    return 1  End If Else   messagebox("提示","身份证位数不对!" )   return 1 End If

return 0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值