📄 frmtgbaoxiu.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmTgBaoXiu
BorderStyle = 1 'Fixed Single
Caption = "住户报修统计"
ClientHeight = 5670
ClientLeft = 45
ClientTop = 330
ClientWidth = 8415
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 5670
ScaleWidth = 8415
Begin VB.Frame Frame1
Caption = "选择排序方式"
Height = 735
Left = 3840
TabIndex = 0
Top = 4080
Width = 3855
Begin VB.ComboBox Combo1
Height = 300
ItemData = "frmTgBaoXiu.frx":0000
Left = 1320
List = "frmTgBaoXiu.frx":001F
TabIndex = 2
Text = "Combo1"
Top = 240
Width = 1575
End
Begin VB.CommandButton cmdOrder
Caption = "排 序"
Height = 255
Left = 3000
TabIndex = 1
Top = 240
Width = 735
End
Begin VB.Label Label1
Caption = "排序方式"
Height = 255
Left = 240
TabIndex = 3
Top = 240
Width = 855
End
End
Begin MSDataGridLib.DataGrid DataGrid2
Height = 1695
Left = 120
TabIndex = 4
Top = 3600
Width = 3495
_ExtentX = 6165
_ExtentY = 2990
_Version = 393216
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
Begin MSDataGridLib.DataGrid DataGrid1
Height = 3135
Left = 120
TabIndex = 5
Top = 240
Width = 7695
_ExtentX = 13573
_ExtentY = 5530
_Version = 393216
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
Begin MSAdodcLib.Adodc Adodc1
Height = 330
Left = 5760
Top = 3720
Visible = 0 'False
Width = 1695
_ExtentX = 2990
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 2
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 3
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "DSN=XiaoQu"
OLEDBString = ""
OLEDBFile = ""
DataSourceName = "XiaoQu"
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "BaoXiu"
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
End
Attribute VB_Name = "frmTgBaoXiu"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs_baoxiu As New ADODB.Recordset
Dim rs_order As New ADODB.Recordset
Dim rs_tg As New ADODB.Recordset
Private Sub cmdOrder_Click()
Dim sql As String
If rs_order.State = adStateOpen Then
rs_order.Close
End If
sql = "select * from BaoXiu order by " & Combo1.Text
rs_order.CursorLocation = adUseClient
rs_order.Open sql, conn, adOpenStatic, adLockOptimistic
'设置DataGrid1的数据源
Set DataGrid1.DataSource = rs_order
DataGrid1.Refresh
'使用分组统计,并显示在DataGrid2中
'首先需要设置DataGrid2可见
DataGrid2.Visible = True
'设置网格不可写
DataGrid2.AllowAddNew = False
DataGrid2.AllowDelete = False
DataGrid2.AllowUpdate = False
Dim sql2 As String
'下面的sql语句已用户选择的combo1.text分组、排序,并且统计同一个combo1.text的数量
sql2 = "select " & Combo1.Text & ", count( " & Combo1.Text & _
" ) as 数量统计 from BaoXiu group by " & Combo1.Text & " order by " & Combo1.Text
If rs_tg.State = adStateOpen Then
rs_tg.Close
End If
rs_tg.CursorLocation = adUseClient
rs_tg.Open sql2, conn, adOpenStatic, adLockOptimistic
'设置DataGrid2的数据源
Set DataGrid2.DataSource = rs_tg
DataGrid2.Refresh
End Sub
Private Sub Form_activate()
Dim X0 As Long
Dim Y0 As Long
'让窗体居中
X0 = Screen.Width
Y0 = Screen.Height
X0 = (X0 - Me.Width) / 2
Y0 = (Y0 - Me.Height) / 2
Me.Move X0, Y0
'开始时设置用于统计的DataGrid2为不可见
DataGrid2.Visible = False
'设置Adodc控件不可见
Adodc1.Visible = False
'设置网格不可写
DataGrid1.AllowAddNew = False
DataGrid1.AllowDelete = False
DataGrid1.AllowUpdate = False
Combo1.ListIndex = 0
'显示全部数据,而不是查询结果数据
Dim sql As String
sql = "select * from BaoXiu order by 报修编号"
rs_baoxiu.CursorLocation = adUseClient
rs_baoxiu.Open sql, conn, adOpenStatic, adLockOptimistic
'设置DataGrid1的数据源
Set DataGrid1.DataSource = rs_baoxiu
DataGrid1.Refresh
End Sub
Private Sub Form_Unload(Cancel As Integer)
'使网格的数据源转向空的Adodc控件,否则有可能无法关闭
Set DataGrid1.DataSource = Adodc1
DataGrid1.Refresh
rs_baoxiu.Close
If rs_order.State = adStateOpen Then
rs_order.Close
End If
If rs_tg.State = adStateOpen Then
rs_tg.Close
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -