📄 frmstatisticsmonthly.frm
字号:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomct2.ocx"
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "msflxgrd.ocx"
Begin VB.Form frmStatisticsMonthly
Caption = "按月统计表"
ClientHeight = 9090
ClientLeft = 375
ClientTop = 1560
ClientWidth = 14625
Icon = "frmStatisticsMonthly.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MDIChild = -1 'True
ScaleHeight = 9090
ScaleWidth = 14625
WindowState = 2 'Maximized
Begin TabDlg.SSTab SSTab1
Height = 8775
Left = 120
TabIndex = 0
Top = 120
Width = 14325
_ExtentX = 25268
_ExtentY = 15478
_Version = 393216
Tabs = 1
TabHeight = 520
ForeColor = 4227327
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "华文行楷"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
TabCaption(0) = "按月统计表"
TabPicture(0) = "frmStatisticsMonthly.frx":0442
Tab(0).ControlEnabled= -1 'True
Tab(0).Control(0)= "Label1"
Tab(0).Control(0).Enabled= 0 'False
Tab(0).Control(1)= "Label2"
Tab(0).Control(1).Enabled= 0 'False
Tab(0).Control(2)= "Label3"
Tab(0).Control(2).Enabled= 0 'False
Tab(0).Control(3)= "DTInputMonth"
Tab(0).Control(3).Enabled= 0 'False
Tab(0).Control(4)= "cmdStat"
Tab(0).Control(4).Enabled= 0 'False
Tab(0).Control(5)= "cmdClose"
Tab(0).Control(5).Enabled= 0 'False
Tab(0).Control(6)= "MSFlexGrid1"
Tab(0).Control(6).Enabled= 0 'False
Tab(0).Control(7)= "MSFlexGrid2"
Tab(0).Control(7).Enabled= 0 'False
Tab(0).ControlCount= 8
Begin MSFlexGridLib.MSFlexGrid MSFlexGrid2
Height = 3495
Left = 120
TabIndex = 6
Top = 5160
Width = 14055
_ExtentX = 24791
_ExtentY = 6165
_Version = 393216
Cols = 7
End
Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1
Height = 3615
Left = 120
TabIndex = 5
Top = 1200
Width = 14055
_ExtentX = 24791
_ExtentY = 6376
_Version = 393216
Cols = 5
End
Begin VB.CommandButton cmdClose
Caption = "关闭(&C)"
Height = 375
Left = 7200
TabIndex = 4
Top = 540
Width = 1095
End
Begin VB.CommandButton cmdStat
Caption = "统计(&Q)"
Height = 375
Left = 5280
TabIndex = 3
Top = 540
Width = 1095
End
Begin MSComCtl2.DTPicker DTInputMonth
Height = 255
Left = 1440
TabIndex = 2
Top = 600
Width = 2295
_ExtentX = 4048
_ExtentY = 450
_Version = 393216
Format = 53477377
UpDown = -1 'True
CurrentDate = 38173
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "费用统计"
Height = 180
Left = 240
TabIndex = 8
Top = 4920
Width = 720
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "图书情况统计"
Height = 180
Left = 240
TabIndex = 7
Top = 960
Width = 1080
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "输入月份:"
Height = 180
Left = 360
TabIndex = 1
Top = 637
Width = 810
End
End
End
Attribute VB_Name = "frmStatisticsMonthly"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim db As Database, rs As Recordset, rs1 As Recordset
Dim LendStr() As String, LendStat() As Integer, LendSort() As Integer
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdStat_Click()
OFFCAT.Play "wave"
Dim dtmInputDate As Date
dtmInputDate = DTInputMonth.Value '当前月份数
Dim strAppName, strSQL As String
Dim intCountSort, intCountBook, intCount As Integer
strAppName = App.Path & "\图书库.mdb"
Set db = DBEngine.OpenDatabase(strAppName, False, True) '共亨、只读
strSQL = "select count(*) as 类别总数 from 图书类别表"
Set rs = db.OpenRecordset(strSQL)
intCountSort = rs.Fields("类别总数")
rs.Close
Set rs = Nothing
strSQL = "select count(*) as 图书总数目 from 图书表"
Set rs1 = db.OpenRecordset(strSQL)
intCountBook = rs1.Fields("图书总数目")
rs1.Close
Set rs1 = Nothing
'给数组赋值
intCount = intCountSort + intCountBook
ReDim Preserve LendStr(intCount, 2), LendStat(intCount, 3), LendSort(intCountSort)
Dim i, j, intNo As Integer
strSQL = "select 图书类别 from 图书类别表"
Set rs = db.OpenRecordset(strSQL)
rs.MoveFirst
intNo = 0
For i = 1 To intCountSort
intNo = intNo + 1
LendSort(i) = intNo
LendStr(intNo, 1) = rs.Fields("图书类别")
LendStr(intNo, 2) = ""
strSQL = "select count(*) as 图书总数目 from 图书表 where 图书种类='" & LendStr(intNo, 1) & "'"
Set rs1 = db.OpenRecordset(strSQL)
intCountBook = rs1.Fields("图书总数目")
rs1.Close
Set rs1 = Nothing
If intCountBook > 0 Then
strSQL = "select 图书编号,图书名称,图书总数,现存数量 from 图书表 where 图书种类='" & LendStr(intNo, 1) & "'"
Set rs1 = db.OpenRecordset(strSQL)
rs1.MoveFirst
For j = 1 To intCountBook
intNo = intNo + 1
LendStr(intNo, 1) = rs1.Fields("图书编号")
LendStr(intNo, 2) = rs1.Fields("图书名称")
LendStat(intNo, 1) = rs1.Fields("图书总数")
LendStat(LendSort(i), 1) = LendStat(LendSort(i), 1) + LendStat(intNo, 1)
LendStat(intNo, 2) = rs1.Fields("现存数量")
LendStat(LendSort(i), 2) = LendStat(LendSort(i), 2) + LendStat(intNo, 2)
LendStat(intNo, 3) = LendStat(intNo, 1) - LendStat(intNo, 2)
LendStat(LendSort(i), 3) = LendStat(LendSort(i), 3) + LendStat(intNo, 3)
rs1.MoveNext
Next j
rs1.Close
Set rs1 = Nothing
End If
rs.MoveNext
Next i
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
'将数据写入网格
MSFlexGrid1.Rows = intCount + 1
'定义网格列宽
MSFlexGrid1.ColWidth(0) = 1500: MSFlexGrid1.ColWidth(1) = 1500
MSFlexGrid1.ColWidth(2) = 1500: MSFlexGrid1.ColWidth(3) = 1500
MSFlexGrid1.ColWidth(4) = 1500
'定义网格标题
MSFlexGrid1.Row = 0
MSFlexGrid1.Col = 0: MSFlexGrid1.Text = "图书类别"
MSFlexGrid1.Col = 1: MSFlexGrid1.Text = "图书名称"
MSFlexGrid1.Col = 2: MSFlexGrid1.Text = "图书总数"
MSFlexGrid1.Col = 3: MSFlexGrid1.Text = "现存数量"
MSFlexGrid1.Col = 4: MSFlexGrid1.Text = "借出本数"
'建立网格数据
For i = 1 To intCount
MSFlexGrid1.Row = i: MSFlexGrid1.Col = 0
MSFlexGrid1.RowHeight(i) = 250
MSFlexGrid1.Text = LendStr(i, 1)
For j = 1 To 4
MSFlexGrid1.Col = j
If j = 1 Then
MSFlexGrid1.Text = LendStr(i, 2)
Else
MSFlexGrid1.Text = LendStat(i, j - 1)
End If
Next j
Next i
End Sub
Private Sub Form_Resize()
SSTab1.Left = (Me.Width - SSTab1.Width) / 2
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -