可以自己写一个,或者对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