机房收费系统之日历控件

二过程:

1日历控件

①这里首先要加上一个日历控件,以便于用户能够方便选择时间:

这里小编有一个非常低级的错误,那就是如下图:


错误的放置方式:


   


正确的放置方式:




②对日历控件的属性设置:format

format有四个属性:效果分别为下图






2:下面要对日期进行判断:

①起始日期不能大于终止日期---这里用到了DATe diff函数


 Dim date1, date2
    
    '不需要对两个日期进行判空,但要比较大小,开始不能大于结束日期
    
        date1 = DTPicker1.Value
        date2 = DTPicker2.Value
        If DateDiff("n", CDate(date1), CDate(date2)) < 0 Then
            MsgBox "起始日期不能大于终止日期,请重新选择日期!", vbOKOnly + vbExclamation, "提示"
            Exit Sub
        Else

②不能选择比当前更大的日期--


'日期不能超过now
        
            If DTPicker1.Value And DTPicker2.Value > Date Then
                MsgBox "小主,日子还没到呢", 48, "提示"
                DTPicker1.Value = Date
                DTPicker2.Value = Date
                Exit Sub
            Else



3确定好日期的选择,然后查询数据库,看选择的时间段内是否有数据:


txtSQL = "select * from recharge_info where date>= '" & DTPicker1.Value & "'and date<= '" & DTPicker2.Value & "'"
                Set mrc = ExecuteSQL(txtSQL, MsgText)
               
                If mrc.EOF Then
                    MsgBox "该时间段内没有数据!", vbOKOnly + vbExclamation, "警告"
                    Exit Sub
                Else

4若数据存在,则显示到MSHFlexGrid中:


 With MSHFlexGrid1
                        .Rows = 1
                        .CellAlignment = 4 '居中
                        .TextMatrix(0, 0) = "学号"
                        .TextMatrix(0, 1) = "卡号"
                        .TextMatrix(0, 2) = "充值金额"
                        .TextMatrix(0, 3) = "充值日期"
                        .TextMatrix(0, 4) = "充值时间"
                        .TextMatrix(0, 5) = "充值教师"

                    Do While Not mrc.EOF
                        .Rows = .Rows + 1
                        .CellAlignment = 4
                        .TextMatrix(.Rows - 1, 0) = mrc.Fields(1)
                        .TextMatrix(.Rows - 1, 1) = mrc.Fields(2)
                        .TextMatrix(.Rows - 1, 2) = mrc.Fields(3)
                        .TextMatrix(.Rows - 1, 3) = mrc.Fields(4)
                        .TextMatrix(.Rows - 1, 4) = mrc.Fields(5)
                        .TextMatrix(.Rows - 1, 5) = mrc.Fields(6)
                        
                        mrc.MoveNext
                    Loop
                    End With
                mrc.Close


日期段分享到此~~

欢迎指出不足

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 21
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 21
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值