以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  如何通过身份证号生成性别、年龄  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=89214)

--  作者:遇江南
--  发布时间:2016/8/17 12:39:00
--  如何通过身份证号生成性别、年龄
老师好,在foxtable表中有身份证号怎样生成性别、年龄?如何设置?
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:问题table.rar


--  作者:大红袍
--  发布时间:2016/8/17 14:38:00
--  

DataColChanged事件

 

If e.DataCol.Name = "身份证号码" Then
    If e.NewValue > "" Then
        e.DataRow("性别") = ReadSex(StrToNarrow(e.NewValue))
        Dim y,m,d As Integer
        DateYMD(ReadBirthDay(StrToNarrow(e.NewValue)),Date.Today,y,m,d)
        e.DataRow("年龄") = y
    End If
End If

 


--  作者:遇江南
--  发布时间:2016/8/17 14:52:00
--  
以下是引用大红袍在2016/8/17 14:38:00的发言:

DataColChanged事件

一、 

If e.DataCol.Name = "身份证号码" Then
    If e.NewValue > "" Then
        e.DataRow("性别") = ReadSex(StrToNarrow(e.NewValue))
        Dim y,m,d As Integer
        DateYMD(ReadBirthDay(StrToNarrow(e.NewValue)),Date.Today,y,m,d)
        e.DataRow("年龄") = y
    End If
End If

 

二、

For Each dc As DataCol In e.DataTable.DataCols

    If e.DataTable.DataCols.Contains(dc.name & "大写") Then

        If e.DataRow.IsNull(dc.name) = False Then

            e.DataRow(dc.name & "大写") =  CUMoney(format(e.DataRow(dc.name), "0.00"))

        Else

            e.DataRow(dc.name & "大写") =  Nothing

        End If

    End If

Next



这两段代码可以同时放在DataColChanged事件吗?


--  作者:大红袍
--  发布时间:2016/8/17 15:00:00
--  
 可以。
--  作者:遇江南
--  发布时间:2016/8/17 15:03:00
--  
以下是引用大红袍在2016/8/17 15:00:00的发言:
 可以。

谢谢图片点击可在新窗口打开查看