📄 form6.frm
字号:
Top = 120
Width = 4095
_ExtentX = 7223
_ExtentY = 5530
_Version = 393216
Rows = 1000
Cols = 4
FixedRows = 0
FixedCols = 0
End
Begin VB.Frame Frame1
BackColor = &H00C0FFFF&
Caption = "请选择查询方式:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 2535
Left = 120
TabIndex = 0
Top = 120
Width = 3975
Begin VB.CommandButton Command8
Caption = "按日期查询"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 240
TabIndex = 16
Top = 1680
Width = 1455
End
Begin VB.CommandButton Command5
Caption = "返回"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2280
TabIndex = 10
Top = 1680
Width = 1455
End
Begin VB.CommandButton Command2
Caption = "按成绩查询"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2280
TabIndex = 2
Top = 600
Width = 1455
End
Begin VB.CommandButton Command1
Caption = "按学号查询"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 240
TabIndex = 1
Top = 600
Width = 1455
End
End
End
Attribute VB_Name = "Form6"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Form6.MSFlexGrid1.Visible = True
Form6.Frame1.Visible = False
Form6.Frame2.Visible = True
Form6.Frame4.Visible = False
Form6.Text1.Text = ""
End Sub
Private Sub Init()
Dim i As Integer
Dim j As Integer
Dim flag As Boolean
MSFlexGrid1.TextMatrix(0, 0) = "学号"
MSFlexGrid1.TextMatrix(0, 1) = "课程编号"
MSFlexGrid1.TextMatrix(0, 2) = "考试时间"
MSFlexGrid1.TextMatrix(0, 3) = "成绩"
For i = 1 To MSFlexGrid1.Rows - 1
For j = 0 To MSFlexGrid1.Cols - 1
MSFlexGrid1.TextMatrix(i, j) = ""
Next
Next
End Sub
Private Sub Command10_Click()
Form6.Frame1.Visible = True
Form6.Frame2.Visible = False
Form6.Frame3.Visible = False
Form6.Frame4.Visible = False
Form6.MSFlexGrid1.Visible = False
End Sub
Private Sub Command2_Click()
Form6.MSFlexGrid1.Visible = True
Form6.Frame1.Visible = False
Form6.Frame2.Visible = False
Form6.Frame3.Visible = True
Form6.Frame4.Visible = False
End Sub
Private Sub Command3_Click() '按学号查询成绩
Dim DBConn As ADODB.Connection
Dim rs As New ADODB.Recordset
Dim s1 As String
Dim i As Integer
Init
Set DBConn = CreateObject("ADODB.Connection")
DBConn.ConnectionString = "DBQ=" + App.Path + "\db1;Driver={Microsoft Access Driver (*.mdb)}"
stu_Id = Text1.Text
s1 = "select * from 成绩表 where stu_Id='" & stu_Id & "'"
If Trim(Text1.Text) = "" Then
MsgBox "查询前请先输入学号", vbOKOnly, "提示!"
Else
Set rs = TransactSQL(s1)
If rs.EOF = True Then
MsgBox "没有所要查询的学生的成绩!", vbOKOnly, "提示!"
Else
i = 1
While Not rs.EOF And Not rs.BOF
MSFlexGrid1.TextMatrix(i, 0) = rs("stu_Id")
MSFlexGrid1.TextMatrix(i, 1) = rs("cou_Id")
MSFlexGrid1.TextMatrix(i, 2) = rs("T_time")
MSFlexGrid1.TextMatrix(i, 3) = rs("Grade")
i = i + 1
rs.MoveNext
Wend
rs.Close
End If
End If
'DBConn.Close
End Sub
Private Sub Command4_Click()
Form6.Frame1.Visible = True
Form6.Frame2.Visible = False
Form6.Frame3.Visible = False
Form6.Frame4.Visible = False
Form6.MSFlexGrid1.Visible = False
End Sub
Private Sub Command5_Click()
Unload Me
Form1.Show
End Sub
Private Sub Command6_Click() '按成绩范围查询学生成绩
Dim DBConn As ADODB.Connection
Dim DBRst As ADODB.Recordset
Dim SqlText As String
Dim s1 As String
Dim i As Integer
Init
Set DBConn = CreateObject("ADODB.Connection")
Set DBRst = New ADODB.Recordset
DBConn.ConnectionString = "DBQ=" + App.Path + "\db1;Driver={Microsoft Access Driver (*.mdb)}"
DBConn.Open
s1 = "Select * from 成绩表 where "
'------------------成绩范围---------------------------
Select Case Combo1.ListIndex
Case 0 '等于
s1 = s1 + " Grade= " + " '" & Text2.Text & "' "
Case 1 '大于
s1 = s1 + " Grade>= " + " '" & Text2.Text & "' "
Case 2 '小于
s1 = s1 + " Grade<= " + " '" & Text2.Text & "' "
End Select
If Trim(Text2.Text) = "" Then
MsgBox "请先输入查寻范围:", vbOKOnly, "提示!"
Else
Set DBRst = DBConn.Execute(s1)
If DBRst.EOF = True Then
MsgBox "没有符合条件的学生成绩信息!", vbOKOnly, "提示!"
Else
i = 1
While Not DBRst.EOF And Not DBRst.BOF
MSFlexGrid1.TextMatrix(i, 0) = DBRst("stu_Id")
MSFlexGrid1.TextMatrix(i, 1) = DBRst("cou_Id")
MSFlexGrid1.TextMatrix(i, 2) = DBRst("T_time")
MSFlexGrid1.TextMatrix(i, 3) = DBRst("Grade")
i = i + 1
DBRst.MoveNext
Wend
DBRst.Close
End If
End If
End Sub
Private Sub Command7_Click()
Form6.Frame1.Visible = True
Form6.Frame2.Visible = False
Form6.Frame3.Visible = False
Form6.MSFlexGrid1.Visible = False
End Sub
Private Sub Command8_Click()
Form6.MSFlexGrid1.Visible = True
Form6.Frame1.Visible = False
Form6.Frame2.Visible = False
Form6.Frame3.Visible = False
Form6.Frame4.Visible = True
End Sub
Private Sub Command9_Click() '按考试日期查询
Dim DBConn As ADODB.Connection
Dim rs As New ADODB.Recordset
Dim s1 As String
Dim i As Integer
Dim s2 As Date
Init
Set DBConn = CreateObject("ADODB.Connection")
DBConn.ConnectionString = "DBQ=" + App.Path + "\db1;Driver={Microsoft Access Driver (*.mdb)}"
DBConn.Open
s2 = Trim(Format(DTPicker1.Value, "yyyy-mm-dd"))
s1 = "select * from 成绩表 where T_time =#" & s2 & "# "
Set rs = TransactSQL(s1)
' 或者:Set rs = DBConn.Execute(s1)
If rs.EOF = True Then
'If rs.EOF = rs.BOF Then
MsgBox "没有符合条件的学生成绩信息!", vbOKOnly, "提示!"
Else
i = 1
While Not rs.EOF And Not rs.BOF
MSFlexGrid1.TextMatrix(i, 0) = rs("stu_Id")
MSFlexGrid1.TextMatrix(i, 1) = rs("cou_Id")
MSFlexGrid1.TextMatrix(i, 2) = rs("T_time")
MSFlexGrid1.TextMatrix(i, 3) = rs("Grade")
i = i + 1
rs.MoveNext
Wend
rs.Close
End If
End Sub
Private Sub Form_Load()
Init
Combo1.ListIndex = 0
Form6.Text2.Text = ""
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -