Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共4 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[求助]帮忙看看这个求年龄的代码。(已解决)

1楼
pc005637 发表于:2011/9/1 13:52:00
有两列:分别是 出生日期 年龄
代码放在DataColChanged事件上
If e.DataCol.Name = "出生日期" Then
If e.NewValue Is Nothing Then
Return
Else
Dim n As Integer = Date.Today.year - e.NewValue.Year
If e.NewValue.AddMonths(n*12) > Date.Today Then
n = n - 1
e.DataRow("年龄") = n
End If
End If
End If

输入出生日期后不能自动出现年龄,求解。
[此贴子已经被作者于2011-9-1 14:21:44编辑过]
2楼
狐狸爸爸 发表于:2011/9/1 13:54:00

If e.DataCol.Name = "出生日期" Then
    If e.NewValue Is Nothing Then

        e.DataRow("年龄") = Nothing
    Else
        Dim n As Integer = Date.Today.year - e.NewValue.Year
        If e.NewValue.AddMonths(n*12) > Date.Today Then
            n = n - 1
        End If

        e.DataRow("年龄") = n
    End If
End If

3楼
pc005637 发表于:2011/9/1 14:21:00
谢谢。解决问题。
4楼
wcs4812 发表于:2011/10/12 9:34:00
顶一下
共4 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02344 s, 2 queries.