📄 frmquery_class.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form Frmquery_class
Caption = "班级查询"
ClientHeight = 5070
ClientLeft = 60
ClientTop = 420
ClientWidth = 7320
LinkTopic = "Form1"
ScaleHeight = 5070
ScaleWidth = 7320
StartUpPosition = 2 '屏幕中心
Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1
Height = 1455
Left = 720
TabIndex = 6
Top = 3120
Width = 6015
_ExtentX = 10610
_ExtentY = 2566
_Version = 393216
End
Begin VB.CommandButton cmd_cancel
Caption = "取消"
Height = 375
Left = 3720
TabIndex = 5
Top = 2400
Width = 855
End
Begin VB.CommandButton cmd_query
Caption = "查询"
Height = 375
Left = 1920
TabIndex = 4
Top = 2400
Width = 855
End
Begin VB.Frame Frame1
Caption = "查询条件"
Height = 1935
Left = 720
TabIndex = 0
Top = 240
Width = 6135
Begin VB.ComboBox class_name
Height = 300
Left = 4080
TabIndex = 8
Top = 360
Width = 1335
End
Begin VB.ComboBox class_no
Height = 300
Left = 2400
TabIndex = 7
Top = 1200
Width = 1215
End
Begin VB.OptionButton Option_classname
Caption = "按班级名称"
Height = 255
Left = 2640
TabIndex = 3
Top = 360
Width = 1455
End
Begin VB.OptionButton Option_classno
Caption = "按班级编号"
Height = 255
Left = 600
TabIndex = 2
Top = 1200
Width = 1335
End
Begin VB.OptionButton Option_all
Caption = "查询全部"
Height = 255
Left = 600
TabIndex = 1
Top = 360
Width = 1455
End
End
End
Attribute VB_Name = "Frmquery_class"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmd_cancel_Click()
Unload Me
End Sub
Private Sub cmd_query_Click()
Dim rs As ADODB.Recordset
Dim i As Integer
Dim j As Integer
If Option_all.Value = True Then
Option_classno.Value = False
Option_classname.Value = False
sqlStr = "select * from classes "
End If
If Option_classname.Value = True Then
Option_all.Value = False
Option_classno.Value = False
class_no.Text = ""
sqlStr = "select * from classes where className like '%" & class_name.Text & "%'"
End If
If Option_classno.Value = True Then
Option_all.Value = False
Option_classname.Value = False
class_name.Text = ""
sqlStr = "select * from classes where classno like '%" & class_no.Text & "%'"
End If
Set rs = executesql(sqlStr, msgText)
If rs.RecordCount = 0 Then
MsgBox "没有查找满足条件的数据!", vbExclamation, "提示"
MSFlexGrid1.Rows = 1
Else
MSFlexGrid1.Rows = rs.RecordCount + 1
MSFlexGrid1.Cols = 3
End If
For i = 0 To MSFlexGrid1.Rows - 1
MSFlexGrid1.RowHeight(i) = 280
Next i
MSFlexGrid1.Row = 0
For i = 0 To MSFlexGrid1.Cols - 1
MSFlexGrid1.Col = i
MSFlexGrid1.FixedAlignment(i) = 4
Select Case i
Case 0
MSFlexGrid1.ColWidth(i) = 600
MSFlexGrid1.Text = "序号"
Case 1
MSFlexGrid1.ColWidth(i) = 2400
MSFlexGrid1.Text = "班级编号"
Case 2
MSFlexGrid1.ColWidth(i) = 2400
MSFlexGrid1.Text = "班级名称"
End Select
Next i
i = 1
While (Not rs.EOF)
MSFlexGrid1.Row = i
For j = 0 To MSFlexGrid1.Cols - 1
MSFlexGrid1.Col = j
MSFlexGrid1.CellAlignment = 4
Select Case j
Case 0
MSFlexGrid1.Text = i
Case 1
MSFlexGrid1.Text = rs.Fields("classno")
Case 2
MSFlexGrid1.Text = rs.Fields("className")
End Select
Next j
i = i + 1
rs.MoveNext
Wend
rs.Close
End Sub
Private Sub Form_Load()
Option_all.Value = False
Option_classno.Value = False
Option_classname.Value = False
initclassno
initclassname
class_no = ""
class_name = ""
End Sub
Private Sub class_no_KeyPress(KeyAscii As Integer)
If KeyAscii = Asc(vbCr) Then
KeyAscii = 0
Call cmd_query_Click
End If
End Sub
Private Sub class_name_KeyPress(KeyAscii As Integer)
If KeyAscii = Asc(vbCr) Then
KeyAscii = 0
Call cmd_query_Click
End If
End Sub
Sub initclassno()
Dim rstclass As ADODB.Recordset
sqlStr = "select classno from classes "
Set rstclass = executesql(sqlStr, msgText)
class_no.Clear
If Not rstclass.EOF Then
Do While Not rstclass.EOF
class_no.AddItem Trim(rstclass.Fields(0))
rstclass.MoveNext
Loop
class_no.ListIndex = 0
Else
MsgBox "你查找的信息不存在", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
rstclass.Close
End Sub
Sub initclassname()
Dim rs As ADODB.Recordset
sqlStr = "select className from classes group by classname "
Set rs = executesql(sqlStr, msgText)
class_name.Clear
If Not rs.EOF Then
Do While Not rs.EOF
class_name.AddItem Trim(rs.Fields(0))
rs.MoveNext
Loop
class_name.ListIndex = 0
Else
MsgBox "你查找的信息不存在!", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
rs.Close
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -