If e.DataCol.Name = "账....号" Then '如果更改的是身份证号码列
Dim skr As Integer = len(e.DataRow("收款人"))
e.DataRow("账号检索") = e.DataRow("收款人") & "【" & e.DataRow("开户行") & "】" & e.DataRow("账号") & " " & e.DataRow("备注")
If e.DataRow.IsNull("账号") Then '身份证号码是否为空
e.DataRow("录入校验") = Nothing '如果为空,则清除出生日期
Else If skr < 50 Then
Dim zh As String = e.DataRow("账号")
e.DataRow("BIN") = LEFT(zh,6)
'e.DataRow("单数") =
'计算3-15位的单数位之各
Dim kd As Integer = val(left(RIGHT(zh,3),1))+val(left(RIGHT(zh,5),1))+val(left(RIGHT(zh,7),1))+val(left(RIGHT(zh,9),1))+val(left(RIGHT(zh,11),1))+val(left(RIGHT(zh,13),1))+val(left(RIGHT(zh,15),1))
'计算2-16位双数位的MOD,和INT之和
Dim km2 As Integer = val(LEFT(RIGHT(zh,2),1)*2) Mod 10
Dim kt2 As Integer = math.floor(LEFT(RIGHT(zh,2),1)*2/10)
Dim km4 As Integer = val(LEFT(RIGHT(zh,4),1)*2) Mod 10
Dim kt4 As Integer = math.floor(LEFT(RIGHT(zh,4),1)*2/10)
Dim km6 As Integer = val(LEFT(RIGHT(zh,6),1)*2) Mod 10
Dim kt6 As Integer = math.floor(LEFT(RIGHT(zh,6),1)*2/10)
Dim km8 As Integer = val(LEFT(RIGHT(zh,8),1)*2) Mod 10
Dim kt8 As Integer = math.floor(LEFT(RIGHT(zh,8),1)*2/10)
Dim km10 As Integer = val(LEFT(RIGHT(zh,10),1)*2) Mod 10
Dim kt10 As Integer = math.floor(LEFT(RIGHT(zh,10),1)*2/10)
Dim km12 As Integer = val(LEFT(RIGHT(zh,12),1)*2) Mod 10
Dim kt12 As Integer = math.floor(LEFT(RIGHT(zh,12),1)*2/10)
Dim km14 As Integer = val(LEFT(RIGHT(zh,14),1)*2) Mod 10
Dim kt14 As Integer = math.floor(LEFT(RIGHT(zh,14),1)*2/10)
Dim km16 As Integer = val(LEFT(RIGHT(zh,16),1)*2) Mod 10
Dim kt16 As Integer = math.floor(LEFT(RIGHT(zh,16),1)*2/10)
Dim ks As Integer = km2 + kt2 +km4 + kt4 +km6 + kt6 +km8 + kt8 +km10 + kt10 +km12 + kt12 +km14 + kt14 +km16 + kt16
'================================================判断17-19位数
Dim ka As Integer
Dim km18 As Integer
Dim kc As Integer
Dim kt18 As Integer
Dim cd As Integer = len(e.DataRow("账号"))
If cd >=17 Then
ka = val(LEFT(RIGHT(zh,17),1))
Else
ka =0
End If
If cd >=18 Then
km18 = val(LEFT(RIGHT(zh,18),1)*2) Mod 10
kt18 = math.floor(LEFT(RIGHT(zh,18),1)*2/10)
Else
km18 = 0
kt18 = 0
End If
If cd >=19 Then
kc = val(LEFT(RIGHT(zh,19),1))
Else
kc = 0
End If
Dim kk As Integer = ka + km18 + kt18 + kc
'根据单数位,双数位,及17-19位情况合与校验位
Dim js As Integer = (kd + ks + kk)*9 Mod 10
Dim jy As Integer = val(right (zh,1))
If js = jy Then
e.DataRow("录入校验") = "正确"
e.DataRow("校验位") = js
Else If js <> jy And skr < 5 Then
e.DataRow("录入校验") = "错误"
e.DataRow("校验位") = js
Else
e.DataRow("录入校验") = "不详"
e.DataRow("校验位") = js
End If
End If
End If
[此贴子已经被作者于2019/4/17 11:22:02编辑过]