以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  根据身份证如何表达式设置性别等信息  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=129548)

--  作者:guxuming85
--  发布时间:2018/12/31 10:56:00
--  根据身份证如何表达式设置性别等信息
老师,根据身份证列,如何在性别,年龄,出生年月,出生月份的列的表达式设置,帮助手册中表达式翻了半天没找到。
--  作者:guxuming85
--  发布时间:2019/1/1 13:13:00
--  
有人知道吗?
--  作者:y2287958
--  发布时间:2019/1/1 17:12:00
--  
http://www.foxtable.com/webhelp/scr/0320.htm
--  作者:有点甜
--  发布时间:2019/1/2 9:37:00
--  

参考,datacolchanged事件

 

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