📄 frmroommum.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Begin VB.Form frmroommum
BackColor = &H00C0C000&
BorderStyle = 1 'Fixed Single
Caption = "寝室成员查询"
ClientHeight = 6900
ClientLeft = 2790
ClientTop = 3180
ClientWidth = 11145
BeginProperty Font
Name = "方正舒体"
Size = 15.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
MaxButton = 0 'False
Picture = "frmroommum.frx":0000
ScaleHeight = 6900
ScaleWidth = 11145
Begin VB.CommandButton cmdprint
BackColor = &H0080C0FF&
Caption = "导出打印"
Enabled = 0 'False
Height = 615
Left = 3720
Style = 1 'Graphical
TabIndex = 13
Top = 5160
Width = 1695
End
Begin VB.ComboBox txtcollege
BackColor = &H00C0E0FF&
Height = 450
ItemData = "frmroommum.frx":192FF
Left = 8400
List = "frmroommum.frx":19306
TabIndex = 12
Top = 4320
Width = 1695
End
Begin VB.ComboBox txtroom
BackColor = &H00C0E0FF&
Height = 450
ItemData = "frmroommum.frx":19314
Left = 5160
List = "frmroommum.frx":1931E
TabIndex = 11
Top = 4320
Width = 1575
End
Begin VB.ComboBox txtdong
BackColor = &H00C0E0FF&
Height = 450
ItemData = "frmroommum.frx":1932E
Left = 1800
List = "frmroommum.frx":19350
TabIndex = 10
Top = 4320
Width = 1335
End
Begin MSHierarchicalFlexGridLib.MSHFlexGrid myflexgrid
Height = 2895
Left = 240
TabIndex = 9
Top = 840
Width = 10335
_ExtentX = 18230
_ExtentY = 5106
_Version = 393216
Rows = 18
Cols = 7
AllowUserResizing= 3
RowSizingMode = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_NumberOfBands = 1
_Band(0).Cols = 7
End
Begin VB.CheckBox Check3
BackColor = &H00C0C0FF&
Caption = "按学院:"
BeginProperty Font
Name = "黑体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 6840
TabIndex = 8
Top = 4320
Width = 1455
End
Begin VB.CheckBox Check2
BackColor = &H00C0C0FF&
Caption = "按寝室号:"
BeginProperty Font
Name = "黑体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3360
TabIndex = 7
Top = 4320
Width = 1695
End
Begin VB.CheckBox Check1
BackColor = &H00C0C0FF&
Caption = "按公寓号:"
BeginProperty Font
Name = "黑体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 120
TabIndex = 6
Top = 4320
Width = 1695
End
Begin VB.CommandButton Command2
Caption = "退出查询"
BeginProperty Font
Name = "黑体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 6120
TabIndex = 5
Top = 5160
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "查询"
BeginProperty Font
Name = "黑体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1560
TabIndex = 4
Top = 5160
Width = 1455
End
Begin VB.Frame Frame2
BackColor = &H0080FFFF&
Height = 255
Left = 120
TabIndex = 3
Top = 480
Width = 9015
End
Begin VB.Frame Frame1
BackColor = &H0080FFFF&
Height = 255
Left = 120
TabIndex = 2
Top = 3840
Width = 8895
End
Begin MSComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 375
Left = 0
TabIndex = 1
Top = 6525
Width = 11145
_ExtentX = 19659
_ExtentY = 661
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 1
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
AutoSize = 1
Object.Width = 19606
Picture = "frmroommum.frx":1937C
Text = "寝室成员查询区"
TextSave = "寝室成员查询区"
EndProperty
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.Line Line1
X1 = 480
X2 = 8160
Y1 = 4800
Y2 = 4800
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "寝室成员信息查询"
BeginProperty Font
Name = "方正舒体"
Size = 15
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3240
TabIndex = 0
Top = 120
Width = 2535
End
End
Attribute VB_Name = "frmroommum"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim txtSQL As String
Private Sub cmdprint_Click()
Dim i As Integer, j As Integer
'Dim txtSQL As String
Dim MsgText As String
Dim expworkbook As Excel.Workbook
Dim expexcel As Excel.Application
Dim mrc As ADODB.Recordset
Set expexcel = New Excel.Application
expexcel.Visible = True
expexcel.SheetsInNewWorkbook = 1
Set expworkbook = expexcel.Workbooks.Add
Call ConnectString
' txtSQL = "select * from hygiene_check "
'myflexgrid
' ConnectDB
'Set mrc = mrc.Execute("select * from hygiene_check")
Set mrc = ExecuteSQL(txtSQL, MsgText)
For i = 0 To mrc.Fields.Count - 1
expexcel.Cells(2, i + 1) = mrc.Fields(i).Name
Next
mrc.MoveFirst
For j = 1 To myflexgrid.Rows
For i = 0 To mrc.Fields.Count - 1
expexcel.Cells(j + 2, i + 1) = CStr(mrc.Fields(i))
Next
mrc.MoveNext
If mrc.EOF Then Exit For
Next
Set expexcel = Nothing
End Sub
Private Sub Command1_Click()
' Dim txtSQL As String
Dim MsgText As String
Dim dd(4) As Boolean
Dim mrc As ADODB.Recordset
Dim sMeg As String
txtSQL = "select * from reward_punish where "
If Check1.Value Then
If Trim(txtdong.Text) = "" Then
sMeg = "栋号不能为空"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtdong.SetFocus
Exit Sub
Else
If Not IsNumeric(Trim(txtdong.Text)) Then
MsgBox "请输入栋号数字!", vbOKOnly + vbExclamation, "警告"
Exit Sub
txtdong.SetFocus
End If
dd(0) = True
txtSQL = txtSQL & "栋号= '" & Val(Trim(txtdong.Text)) & "'"
End If
End If
If Check2.Value Then
If Trim(txtroom.Text) = "" Then
sMeg = "寝室号不能为空"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtroom.SetFocus
Exit Sub
Else
dd(1) = True
If dd(0) Then
txtSQL = txtSQL & "and 寝室号= '" & txtroom.Text & "'"
Else
txtSQL = txtSQL & "寝室号 = '" & txtroom.Text & "'"
End If
End If
End If
If Check3.Value Then
If Trim(txtcollege.Text) = "" Then
sMeg = "学院不能为空"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtcollege.SetFocus
Exit Sub
Else
dd(2) = True
If dd(0) Or dd(1) Then
txtSQL = txtSQL & "and 学院= '" & txtcollege.Text & "'"
Else
txtSQL = txtSQL & "学院= '" & txtcollege.Text & "'"
End If
End If
End If
If Not (dd(0) Or dd(1) Or dd(2) Or dd(3)) Then
MsgBox "请设置查询方式!", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
txtSQL = txtSQL & " order by 栋号,寝室号"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.RecordCount > 0 Then
cmdprint.Enabled = True
Else
cmdprint.Enabled = False
End If
With myflexgrid
.Rows = 2
.CellAlignment = 4
.TextMatrix(1, 0) = "栋号"
.TextMatrix(1, 1) = "寝室号"
.TextMatrix(1, 2) = "年级"
.TextMatrix(1, 3) = "学院"
.TextMatrix(1, 4) = "专业"
.TextMatrix(1, 5) = "寝室成员"
.TextMatrix(1, 6) = "电话"
Do While Not mrc.EOF
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = mrc.Fields(0)
.TextMatrix(.Rows - 1, 1) = mrc.Fields(1)
.TextMatrix(.Rows - 1, 2) = mrc.Fields(2)
.TextMatrix(.Rows - 1, 3) = mrc.Fields(3)
.TextMatrix(.Rows - 1, 4) = mrc.Fields(4)
.TextMatrix(.Rows - 1, 5) = mrc.Fields(5)
.TextMatrix(.Rows - 1, 6) = mrc.Fields(8)
mrc.MoveNext
Loop
End With
mrc.Close
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -