📄 form1.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form Form1
Caption = "某一时间段内数据统计"
ClientHeight = 4350
ClientLeft = 60
ClientTop = 345
ClientWidth = 8460
LinkTopic = "Form1"
ScaleHeight = 4350
ScaleWidth = 8460
StartUpPosition = 1 '所有者中心
Begin VB.TextBox d1
Height = 270
Left = 4380
TabIndex = 9
Top = 210
Visible = 0 'False
Width = 705
End
Begin VB.TextBox d2
Height = 270
Left = 5220
TabIndex = 8
Top = 240
Visible = 0 'False
Width = 705
End
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access"
DatabaseName = "C:\mrjd\kfgl.mdb"
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 450
Left = -165
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "gzmx"
Top = 1545
Visible = 0 'False
Width = 1140
End
Begin VB.Data Data2
Caption = "Data1"
Connect = "Access"
DatabaseName = "C:\mrjd\kfgl.mdb"
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 450
Left = -150
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "gzmx"
Top = 1905
Visible = 0 'False
Width = 1140
End
Begin VB.CommandButton Command2
Caption = "退出"
Height = 390
Left = 6225
TabIndex = 0
Top = 3870
Width = 2115
End
Begin MSFlexGridLib.MSFlexGrid MS4
Bindings = "Form1.frx":0000
Height = 3255
Left = 150
TabIndex = 1
Top = 555
Width = 8205
_ExtentX = 14473
_ExtentY = 5741
_Version = 393216
FixedCols = 0
AllowUserResizing= 3
End
Begin MSComCtl2.DTPicker DTP1
Height = 285
Left = 690
TabIndex = 2
Top = 180
Width = 1425
_ExtentX = 2514
_ExtentY = 503
_Version = 393216
Format = 24444929
CurrentDate = 37132
End
Begin MSComCtl2.DTPicker DTP2
Height = 285
Left = 2565
TabIndex = 3
Top = 180
Width = 1410
_ExtentX = 2487
_ExtentY = 503
_Version = 393216
Format = 24444929
CurrentDate = 37132
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Height = 315
Left = 1470
TabIndex = 7
Top = 3900
Width = 3045
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "合计欠款金额:"
Height = 315
Left = 150
TabIndex = 6
Top = 3915
Width = 1275
End
Begin VB.Label Label1
Caption = "日期"
Height = 300
Left = 165
TabIndex = 5
Top = 225
Width = 570
End
Begin VB.Label Label2
Caption = "到"
Height = 285
Left = 2250
TabIndex = 4
Top = 225
Width = 240
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Activate()
Data1.RecordSource = "select * from gzmx"
Data1.Refresh
'SQL查询统计语句
Data2.RecordSource = "select sum(欠款金额)as 欠款,count(*)as 序号 from gzmx"
Data2.Refresh
If Data2.Recordset.Fields(0) <> "" Then Label4.Caption = Data2.Recordset.Fields(0) & "元" Else Label4.Caption = "0.00"
'日期为长日期
DTP1.Value = Date - 30
DTP2.Value = Date
'设置MSflexgird表格的宽度
MS4.ColWidth(0) = 12 * 25 * 4
MS4.ColWidth(8) = 12 * 25 * 5
End Sub
Private Sub Form_Load()
'自动识别数据库路径
Data1.DatabaseName = App.Path & "\kfgl.mdb"
Data2.DatabaseName = App.Path & "\kfgl.mdb"
End Sub
Private Sub DTP1_Change()
d1.Text = DTP1.Value
d2.Text = DTP2.Value
If DTP1.Value < DTP2.Value Then
Data1.RecordSource = "select * from gzmx where gzmx.日期 between " + Chr(35) + d1.Text + Chr(35) + "and " + Chr(35) + d2.Text + Chr(35) + "order by 日期,时间"
Data1.Refresh
Data2.RecordSource = "select sum(欠款金额)as 欠款,count(*)as 序号 from gzmx where gzmx.日期 between " + Chr(35) + d1.Text + Chr(35) + "and " + Chr(35) + d2.Text + Chr(35) + ""
Data2.Refresh
If Data2.Recordset.Fields(0) <> "" Then Label4.Caption = Data2.Recordset.Fields(0) & "元" Else Label4.Caption = "0.00"
Else
MsgBox "系统不允许日期颠倒"
DTP2.Value = DTP1.Value + 1
End If
End Sub
Private Sub DTP2_Change()
d1.Text = DTP1.Value
d2.Text = DTP2.Value
If DTP1.Value < DTP2.Value Then
Data1.RecordSource = "select * from gzmx where gzmx.日期 between " + Chr(35) + d1.Text + Chr(35) + "and " + Chr(35) + d2.Text + Chr(35) + "order by 日期,时间"
Data1.Refresh
Data2.RecordSource = "select sum(欠款金额)as 欠款,count(*)as 序号 from gzmx where gzmx.日期 between " + Chr(35) + d1.Text + Chr(35) + "and " + Chr(35) + d2.Text + Chr(35) + ""
Data2.Refresh
If Data2.Recordset.Fields(0) <> "" Then Label4.Caption = Data2.Recordset.Fields(0) & "元" Else Label4.Caption = "0.00"
Else
DTP2.Value = DTP1.Value + 1
MsgBox "系统不允许日期颠倒"
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -