foxtable根据身份证号码计算年龄和生日
If e.DataCol.Name = "证件号码" Then '是身份证号码发生变化吗?If e.DataRow.IsNull("证件号码") Then '身份证号码是否为空
e.DataRow("生日") = Nothing '如果为空,则清除出生日期
Else
'否则从身份证号码列中提取出生日期
e.DataRow("生日") = ReadBirthday(e.DataRow("证件号码"))
End If
End If
Select Case e.DataCol.Name
Case "生日"
If e.DataRow.IsNull("生日") Then'身份证号码是否为空
e.DataRow("年龄") = Nothing '如果为空,则清除年龄
Else
Dim d As Date = e.NewValue
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
ReadSex
从身份证号码中读取性别。
语法
ReadSex(Value)
Value:身份证号码
例如:
Dim Identify As String = "410110197109172433"
Dim Sex As String = ReadSex(Identify)
Output.Show(Sex)
上述代码的输出结果是“男
页:
[1]