以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 关于按钮实现上一月下一个月汇总问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=96857) |
|
-- 作者:南望 -- 发布时间:2017/3/1 9:47:00 -- 关于按钮实现上一月下一个月汇总问题 窗口中有三个按钮,分别实现上一月、本月、下一月的汇总某列的功能,上一月及本月的按钮功能已经实现,如何实现下一月按钮功能?由于加AddMonths(-1)是在当前月的基础上减一个月,如果在当前基础加一个月不符合实际。 Dim Filter As String Dim Zhichu As Double Dim ShouRu As Double Dim y As Integer = Date.Today.Year Dim m As Integer = Date.Today.Month Dim FirstDay As New Date(y, m, 1) FirstDay = FirstDay.AddMonths(-1) y = FirstDay.Year m = FirstDay.Month e.Form.Controls("Label6").text = m Dim LastDay As New Date(y, m, Date.DaysInMonth(y, m)) Filter = "日期 >= #" & FirstDay & "# And 日期 <= #" & LastDay & "#" msgbox(filter) ShouRu = DataTables("收入表").SqlCompute("Sum(收入金额)",Filter) Zhichu = DataTables("支出表").SqlCompute("Sum(支出金额)",Filter) e.Form.Controls("Label7").text = Format(Shouru,"c") e.Form.Controls("Label8").text = Format(Zhichu,"c")
|
|
-- 作者:wyz20130512 -- 发布时间:2017/3/1 10:06:00 --
[此贴子已经被作者于2017/3/1 10:42:25编辑过]
|
|
-- 作者:南望 -- 发布时间:2017/3/1 10:09:00 -- AddMonths(-1)上个月的 |
|
-- 作者:南望 -- 发布时间:2017/3/1 10:10:00 -- 例如:本月是3月份,点上一月按钮为2月份,再点下一月应该还为3月。 |
|
-- 作者:南望 -- 发布时间:2017/3/1 10:27:00 -- 老师们? |
|
-- 作者:有点色 -- 发布时间:2017/3/1 10:45:00 -- AfterLoad事件
vars("date") = Date.Today
本月
Dim Filter As String Dim Zhichu As Double
Dim ShouRu As Double
Dim y As Integer = vars("date").Year
Dim m As Integer = vars("date").Month
Dim FirstDay As New Date(y, m, 1)
vars("date") = FirstDay 上月
Dim Filter As String Dim Zhichu As Double
Dim ShouRu As Double
Dim y As Integer = vars("date").Year
Dim m As Integer = vars("date").Month
Dim FirstDay As New Date(y, m, 1) FirstDay = FirstDay.AddMonths(-1)
vars("date") = FirstDay |
|
-- 作者:南望 -- 发布时间:2017/3/1 11:12:00 -- 上月代码没问题,但执行完上一月代码再执行本月代码显示的不是现在的月份而是上一月的值 。 |
|
-- 作者:南望 -- 发布时间:2017/3/1 12:14:00 -- 本月的值不是显示上一个月就显示下一个月 |
|
-- 作者:有点色 -- 发布时间:2017/3/1 12:30:00 -- 哦,本月代码改一下
Dim Filter As String Dim Zhichu As Double
Dim ShouRu As Double
Dim y As Integer = Date.Today.Year
Dim m As Integer = Date.Today.Month
Dim FirstDay As New Date(y, m, 1) vars("date") = FirstDay |