以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 碰到一个离奇的问题,关于生日提醒(已解决) (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=27595) |
||||
-- 作者:halflive -- 发布时间:2013/1/5 15:28:00 -- 碰到一个离奇的问题,关于生日提醒(已解决) 自己做的一个生日提醒窗体,原先运行好好的,到了2013年就运行不正常了,不过把表格内容清掉以后又正常了,是在匪夷所思,请大家帮忙看看,感激涕零…… 不说了,上图,上项目文件
窗口是“生日提醒”的afterload事件,去年运行都正常,今年就出问题了,还有,如果没有数据是不会出问题的,有数据就出问题了
[此贴子已经被作者于2013-1-6 11:42:18编辑过]
|
||||
-- 作者:lin_hailun -- 发布时间:2013/1/5 15:47:00 -- 生日提醒通用代码。 Dim ids As String Dim n As Integer = 9 \'未来天数,含今天 Dim eDate As Date = Date.Today.AddDays(n) For Each dr As DataRow In DataTables("员工").Select("姓名 is not null") Dim month As Integer = dr("生日").Month Dim day As Integer = dr("生日").Day Dim sDate As Date = new Date(Date.Today.Year, month, day) Dim days As TimeSpan = eDate - sDate If days.TotalDays >= 0 AndAlso days.TotalDays <= n OrElse days.TotalDays > 365 Then ids = ids & "," & dr("_Identify") \'记录生日的行号 End If Next If ids > "" Then ids = ids.Trim(",") messagebox.show("未来"& n &"天内是" & ids & "的生日,给他们送去祝福吧.","生日提醒") Tables("窗口1_table1").filter = "[_Identify] In (" & ids &")" End If |
||||
-- 作者:halflive -- 发布时间:2013/1/6 8:50:00 -- 没用,还是一样的错误提示!问题好像出再这一行“Dim sDate As Date = new Date(Date.Today.Year, month, day)”
删掉就正常了。 以下是引用lin_hailun在2013-1-5 15:47:00的发言:
生日提醒通用代码。 Dim ids As String Dim n As Integer = 9 \'未来天数,含今天 Dim eDate As Date = Date.Today.AddDays(n) For Each dr As DataRow In DataTables("员工").Select("姓名 is not null") Dim month As Integer = dr("生日").Month Dim day As Integer = dr("生日").Day Dim sDate As Date = new Date(Date.Today.Year, month, day) Dim days As TimeSpan = eDate - sDate If days.TotalDays >= 0 AndAlso days.TotalDays <= n OrElse days.TotalDays > 365 Then ids = ids & "," & dr("_Identify") \'记录生日的行号 End If Next If ids > "" Then ids = ids.Trim(",") messagebox.show("未来"& n &"天内是" & ids & "的生日,给他们送去祝福吧.","生日提醒") Tables("窗口1_table1").filter = "[_Identify] In (" & ids &")" End If |
||||
-- 作者:程兴刚 -- 发布时间:2013/1/6 8:55:00 -- 调整年、月、日顺序看看! |
||||
-- 作者:halflive -- 发布时间:2013/1/6 9:05:00 -- 以下是引用程兴刚在2013-1-6 8:55:00的发言:
调整年、月、日顺序看看! 怎么调? |
||||
-- 作者:lin_hailun -- 发布时间:2013/1/6 9:42:00 -- 代码这样写。忘记判断闰年2月29号的情况了。 Dim ids As String Dim n As Integer = 9 \'未来天数,含今天 Dim eDate As Date = Date.Today.AddDays(n) For Each dr As DataRow In DataTables("基本信息").Select("出生日期 is not null") Dim month As Integer = dr("出生日期").Month Dim day As Integer = dr("出生日期").Day If month = 2 AndAlso day = 29 Then If Date.IsLeapYear(Date.Today.Year) = False Then day = 28 End If Dim sDate As Date = new Date(Date.Today.Year, month, day) Dim days As TimeSpan = eDate - sDate If days.TotalDays >= 0 AndAlso days.TotalDays <= n OrElse days.TotalDays > 365 Then ids = ids & "," & dr("_Identify") \'记录生日的行号 End If Next If ids > "" Then ids = ids.Trim(",") messagebox.show("未来"& n &"天内是" & ids & "的生日,给他们送去祝福吧.","生日提醒") Tables("基本信息").filter = "[_Identify] In (" & ids &")" End If |
||||
-- 作者:halflive -- 发布时间:2013/1/6 11:42:00 -- 问题终于解决了,非常感谢。 |