📄 frmlistdept.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "Msflxgrd.ocx"
Begin VB.Form frmListDept
Caption = "部门列表"
ClientHeight = 4080
ClientLeft = 60
ClientTop = 345
ClientWidth = 5940
LinkTopic = "Form1"
ScaleHeight = 4080
ScaleWidth = 5940
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton cmdCancel
Caption = "返回(&C)"
Height = 375
Left = 2040
TabIndex = 2
Top = 3360
Width = 1695
End
Begin MSFlexGridLib.MSFlexGrid fgDept
Height = 2655
Left = 120
TabIndex = 0
Top = 600
Width = 5655
_ExtentX = 9975
_ExtentY = 4683
_Version = 393216
End
Begin VB.Label Label1
Caption = "部门情况列表"
BeginProperty Font
Name = "MS Sans Serif"
Size = 18
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1800
TabIndex = 1
Top = 120
Width = 2175
End
End
Attribute VB_Name = "frmListDept"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public sqlStr As String
Public msgText As String
Sub queryAllDepts()
Dim rs As ADODB.Recordset
Dim i As Integer
Dim j As Integer
sqlStr = "select * from department"
Set rs = ExecuteSQL(sqlStr, msgText)
If rs.RecordCount = 0 Then
MsgBox "没有查找满足条件的数据!", vbExclamation, "提示"
fgDept.Rows = 1
Else
fgDept.Rows = rs.RecordCount + 1
fgDept.Cols = 6
'Print fgDept.Rows
'设定行高
For i = 0 To fgDept.Rows - 1
fgDept.RowHeight(i) = 280
Next i
'设定列的属性
fgDept.Row = 0
For i = 0 To fgDept.Cols - 1
fgDept.Col = i '指定当前列为第i列
fgDept.FixedAlignment(i) = 4 '每列内容居中显示
Select Case i
Case 0
fgDept.ColWidth(i) = 620 '设定列宽
fgDept.Text = "序号"
Case 1
fgDept.ColWidth(i) = 620 '设定列宽
fgDept.Text = "编号"
Case 2
fgDept.ColWidth(i) = 1000 '设定列宽
fgDept.Text = "部门名称"
Case 3
fgDept.ColWidth(i) = 1000 '设定列宽
fgDept.Text = "部门电话"
Case 4
fgDept.ColWidth(i) = 1000 '设定列宽
fgDept.Text = "办公室"
Case 5
fgDept.ColWidth(i) = 1000 '设定列宽
fgDept.Text = "备注"
End Select
Next i
'rs.MoveFirst
i = 1
While (Not rs.EOF)
fgDept.Row = i
For j = 0 To fgDept.Cols - 1
fgDept.Col = j '设置当前为列为第j列
fgDept.CellAlignment = 4 '每列内容居中显示
Select Case j
Case 0
fgDept.Text = "" & i
Case 1
fgDept.Text = rs.Fields("no")
Case 2
fgDept.Text = rs.Fields("departName")
Case 3
fgDept.Text = rs.Fields("telno")
Case 4
fgDept.Text = rs.Fields("roomNo")
Case 5
fgDept.Text = rs.Fields("memo")
End Select
Next j
rs.MoveNext
i = i + 1
Wend
fgDept.Visible = True
End If
rs.Close
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub Form_Load()
queryAllDepts
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -