以文本方式查看主题

-  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=76741)

--  作者:1327853827
--  发布时间:2015/11/4 11:32:00
--  根据身份证求年龄的问题
我在表datecolchenged的事件中写了
Dim ns As String = e.DataRow("身份证号").Substring(6,4)
If e.DataRow("身份证号") IsNot Nothing Then
    e.DataRow("年龄") = Date.Today.year - Val(ns)
Else
    e.DataRow("年龄") = Nothing
End If
为什么我重置身份证号列,只转换了240行是正确的,后面的都变成了负数

--  作者:1327853827
--  发布时间:2015/11/4 11:35:00
--  
补充说明一下,我的这张表有5000多行,用的是试用版


--  作者:大红袍
--  发布时间:2015/11/4 11:37:00
--  

If e.DataRow.isnull("身份证号") = Nothing Then
    Dim d As Date = ReadBirthDay(e.DataRow("身份证号"))
    e.DataRow("年龄") = Date.Today.year - d.year
Else
    e.DataRow("年龄") = Nothing
End If

--  作者:1327853827
--  发布时间:2015/11/4 11:56:00
--  
谢谢,


--  作者:飞
--  发布时间:2015/11/4 17:45:00
--  
数据多的话用SQL好一些