生日提醒通用代码。
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
|