Foxtable(狐表)用户栏目专家坐堂 → ValidPIN代码不支持15位的身份证号码怎么办?(自己解决了)


  共有10850人关注过本帖树形打印复制链接

主题:ValidPIN代码不支持15位的身份证号码怎么办?(自己解决了)

帅哥哟,离线,有人找我吗?
lin_hailun
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:狐神 帖子:6708 积分:34304 威望:0 精华:11 注册:2012/8/18 23:10:00
  发帖心情 Post By:2012/11/28 9:49:00 [显示全部帖子]

 可以自己写一个,或者对15位的转换一下,升级到18位。

以下是引用明丰在2012-11-10 10:37:00的发言:

身份证号码15位、18位可以同时输入了,请各位测试。

 

'表属性-数据-DataColChanged
If e.DataCol.Name = "身份证号" Then
    If e.DataRow.IsNull("身份证号") Then
        e.DataRow("密码") = Nothing
    Else
        Dim d As String = e.DataRow("身份证号")
        For i As Integer = 0 To d.Length - 1
            If Char.IsLetterOrDigit(d.Chars(i)) = False Then
                Messagebox.Show("身份证号码不正确!")
                e.DataRow("密码") = Nothing
                Return
            End If
        Next
        Dim r2,r3,r4,r5 As String
        If d.length = 15 Then
            Dim r1 As String = d.Substring(6,2)
            If r1 = "00" Then
            Else
                d = d.Insert(6,"19")
                r2 = StrReverse(d)
                For i As Integer = 17 To 1 Step -1
                    r3 = r2.Chars(i-1)
                    r4 = r4 + ( r3 * ((2 ^ i) Mod 11 )) '加权因子
                Next
            End If
            r4 = r4 Mod 11
            If r4 = "0" Then
                r4 = "1"
            ElseIf r4 = "1" Then
                r4 = "0"
            ElseIf r4 = "2" Then
                r4 = "X"
            ElseIf r4 = "3" Then
                r4 = "9"
            ElseIf r4 = "4" Then
                r4 = "8"
            ElseIf r4 = "5" Then
                r4 = "7"
            ElseIf r4 = "6" Then
                r4 = "6"
            ElseIf r4 = "7" Then
                r4 = "5"
            ElseIf r4 = "8" Then
                r4 = "4"
            ElseIf r4 = "9" Then
                r4 = "3"
            ElseIf r4 = "10" Then
                r4 = "2"
            End If
            r5 = d.SubString(d.length - 6,6) '6位密码
            d = d & r4 '15位升18位
        End If
       
        If ValidPIN(d) Then
            If r5 Is Nothing Then
                d = right(d,6)
            Else
                d = r5
            End If
            e.DataRow("密码") = d
        Else
            messagebox.show("身份证号码不正确!")
            e.DataRow("密码") = Nothing
        End If
    End If
End If



 回到顶部