我试了还是不行啊
If e.DataCol.Name = "身份证号" Then '是身份证号发生变化吗?
If e.DataRow.IsNull("身份证号") Then '身份证号是否为空
e.DataRow("出生日期") = Nothing '如果为空,则清除出生日期
e.DataRow("性别") = Nothing '如果为空,则清除性别
Else
'否则从身份证号码列中提取出生日期
e.DataRow("出生日期") = ReadBirthday(e.DataRow("身份证号"))
e.DataRow("性别") = ReadSex(e.DataRow("身份证号"))
End If
End If
If e.DataCol.Name = "出生日期" Then
If e.DataRow.IsNull("出生日期") Then '如果没有输入出生日期
e.DataRow("年龄") = Nothing '则清空年龄
Else
'否则计算年龄
e.DataRow("年龄") = Date.Today.Year - e.DataRow("出生日期").Year
End If
End If
年龄是这样计算得到的
[此贴子已经被作者于2012-7-9 18:51:46编辑过]