各位老师,大家下午好!我是复制下面的代码(感谢提供代码的老师)自动提取人员信息表中的性别、出生日期和年龄的,但是有些人死亡了,我想让死亡的人员年龄在死亡当日自动停止计算(或者说就计算到死亡当日),请问一下我该怎样增加代码进去呢?感谢老师的指导。
此主题相关图片如下:截图.png

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
'否则从出生日期列中提取出年龄
Dim n As Integer= Date.Today.Year - e.DataRow("出生日期").Year
If e.DataRow("出生日期").AddMonths(n*12) > Date.Today Then
n = n -1
End If
e.DataRow("年龄") = n
End If
End If
[此贴子已经被作者于2020/3/14 18:03:31编辑过]