机房收费系统之日历控件

来源:互联网 发布:恢复手机数据的软件 编辑:程序博客网 时间:2024/05/23 00:48

二过程:

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


日期段分享到此~~

欢迎指出不足

原创粉丝点击