麻烦版猪大大给看看呗,我这玩意儿,
一、电话号会提示错误,但是位数多了他说自动截取,并且我希望是有错误就不保存,他现在把错误保存下来了。
二、身份证号码不提示位数错误,只提示调用错误。
三、我这三个语句的关系怎么修正?是不是要把后两个放在第一个语句的开头和结尾中间去啊?
Select Case e.DataCol.Name
Case "身份证号"
If e.DataRow.IsNull("身份证号") Then '身份证号码是否为空
e.DataRow("出生日期") = Nothing '如果为空,则清除出生日期
e.DataRow("性别") = Nothing '如果为空,则清除出生日期
e.DataRow("年龄") = Nothing '如果为空,则清除年龄
Else
'否则从身份证号码列中提取出生日期
e.DataRow("出生日期") = ReadBirthday(e.DataRow("身份证号"))
e.DataRow("性别") = ReadSex(e.DataRow("身份证号"))
Dim d As Date = ReadBirthday(e.DataRow("身份证号"))
Dim y As Integer = d.year
If format(d, "MMdd") <= Format(Date.Today, "MMdd") Then
e.DataRow("年龄") = Date.Today.Year - y
Else
e.DataRow("年龄") = Date.Today.Year - y -1
End If
End If
End Select
If e.DataCol.name = "身份证号" Then
If e.newvalue<>Nothing AndAlso e.newvalue.length <> 18 Then
msgbox("有错,请重新核对")
e.cancel = True
End If
End If
If e.DataCol.name = "手机号码大号" Then
If e.newvalue<>Nothing AndAlso e.newvalue.length <> 11 Then
msgbox("有错,请重新核对")
e.cancel = True
End If
End If
[此贴子已经被作者于2019/3/12 15:04:11编辑过]