frmlistclass.frm
来自「数据库课程设计」· FRM 代码 · 共 153 行
FRM
153 行
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "Msflxgrd.ocx"
Begin VB.Form frmListClass
Caption = "班级列表"
ClientHeight = 3720
ClientLeft = 60
ClientTop = 345
ClientWidth = 4455
LinkTopic = "Form1"
ScaleHeight = 3720
ScaleWidth = 4455
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton cmdOK
Caption = "返回(&C)"
Height = 375
Left = 1440
TabIndex = 2
Top = 3240
Width = 1335
End
Begin MSFlexGridLib.MSFlexGrid fgClass
Height = 2415
Left = 120
TabIndex = 1
Top = 720
Width = 4215
_ExtentX = 7435
_ExtentY = 4260
_Version = 393216
End
Begin VB.Label Label1
Caption = "班级情况一览表"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1200
TabIndex = 0
Top = 240
Width = 1815
End
End
Attribute VB_Name = "frmListClass"
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
Private Sub queryClass()
Dim rs As ADODB.Recordset
Dim i As Integer
Dim j As Integer
sqlStr = "select * from classInfo"
Set rs = ExecuteSQL(sqlStr, msgText)
If rs.RecordCount = 0 Then
MsgBox "没有查找满足条件的数据!", vbExclamation, "提示"
fgClass.Rows = 1
Else
fgClass.Rows = rs.RecordCount + 1
fgClass.Cols = 3
'设定行高
For i = 0 To fgClass.Rows - 1
fgClass.RowHeight(i) = 280
Next i
'设定列的属性
fgClass.Row = 0
For i = 0 To fgClass.Cols - 1
fgClass.Col = i '指定当前列为第i列
fgClass.FixedAlignment(i) = 4 '每列内容居中显示
Select Case i
Case 0
fgClass.ColWidth(i) = 1000 '设定列宽
fgClass.Text = "序号"
Case 1
fgClass.ColWidth(i) = 1200 '设定列宽
fgClass.Text = "班级编号"
Case 2
fgClass.ColWidth(i) = 1800 '设定列宽
fgClass.Text = "班级名称"
End Select
Next i
'rs.MoveFirst
i = 1
While (Not rs.EOF)
fgClass.Row = i
For j = 0 To fgClass.Cols - 1
fgClass.Col = j '设置当前为列为第j列
fgClass.CellAlignment = 4 '每列内容居中显示
Select Case j
Case 0
fgClass.Text = "" & i
Case 1
fgClass.Text = rs.Fields("classNo")
Case 2
fgClass.Text = rs.Fields("className")
End Select
Next j
rs.MoveNext
i = i + 1
Wend
End If
rs.Close
End Sub
Private Sub cmdOK_Click()
Unload Me
End Sub
Private Sub Form_Load()
'窗体居中显示
Me.Top = (Screen.Height - Me.Height) \ 2
Me.Left = (Screen.Width - Me.Width) \ 2
queryClass
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?