以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]起始日期  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=45088)

--  作者:zyys2813
--  发布时间:2014/1/15 14:27:00
--  [求助]起始日期

窗口的起始日期和结束日期默认为上个月21日和本月20日,红色部分怎么写,或是有没有更简单的代码,谢谢

 

Dim dt As Date = Date.Today
Dim dy As Integer = dt.year
Dim dm As Integer = dt.month

Dim FirstDay As Date = New Date(dy,dm-1,21)
Dim LastDay As Date = New Date(dy,dm,20)

e.Form.Controls("报表起始日期").value = firstday
e.Form.Controls("报表结束日期").value = lastday


--  作者:zyys2813
--  发布时间:2014/1/15 14:41:00
--  

Dim dt As Date = Date.Today
Dim dy As Integer = dt.year
Dim dm As Integer = dt.month

Dim dts As Date = Date.Today.AddMonths(-1)
Dim dys As Integer = dts.year
Dim dms As Integer = dts.month

Dim FirstDay As Date = New Date(dys,dms,21)
Dim LastDay As Date = New Date(dy,dm,20)

e.Form.Controls("报表起始日期").value = firstday
e.Form.Controls("报表结束日期").value = lastday

 

 

用笨办法解决了,不知道有没有简洁的


--  作者:Bin
--  发布时间:2014/1/15 15:07:00
--  
挺好的,也不影响效率.可以了.
--  作者:狐狸爸爸
--  发布时间:2014/1/15 15:08:00
--  

Dim dt As Date = Date.Today
Dim dy As Integer = dt.year
Dim dm As Integer = dt.month

Dim LastDay As Date = New Date(dy,dm,20)
Dim FirstDay As Date = LastDay.AddMonths(-1).AddDays(1)


--  作者:lsy
--  发布时间:2014/1/15 15:08:00
--  
e.Form.Controls("DateTimePicker1").Value = CDate(Format(Date.Today.AddMonths(- 1),"Y")).AddDays(20)
e.Form.Controls("DateTimePicker2").Value = CDate(Format(Date.Today,"Y")).AddDays(19)

--  作者:zyys2813
--  发布时间:2014/1/15 15:45:00
--  

受教了