📄 form4.frm
字号:
VERSION 5.00
Begin VB.Form Form4
Caption = "统计"
ClientHeight = 4500
ClientLeft = 60
ClientTop = 345
ClientWidth = 8340
LinkTopic = "Form4"
ScaleHeight = 4500
ScaleWidth = 8340
StartUpPosition = 3 'Windows Default
Begin VB.TextBox CountText
Height = 2775
Left = 240
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 4
Top = 1440
Width = 7695
End
Begin VB.CommandButton ExitCommand
Caption = "退出"
Height = 495
Left = 6480
TabIndex = 3
Top = 120
Width = 975
End
Begin VB.CommandButton StuNoCommand
Caption = "统计"
Height = 495
Left = 4920
TabIndex = 2
Top = 120
Width = 1095
End
Begin VB.TextBox CourseText
Height = 495
Left = 1920
TabIndex = 1
Top = 120
Width = 2655
End
Begin VB.Label Label2
Caption = "可选课程有:高数,英语,物理,计算机,C语言"
Height = 375
Left = 480
TabIndex = 5
Top = 840
Width = 3615
End
Begin VB.Label Label1
Caption = "输入课程名:"
Height = 375
Left = 480
TabIndex = 0
Top = 240
Width = 1215
End
End
Attribute VB_Name = "Form4"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Conn As ADODB.Connection
Dim rs As ADODB.Recordset
Private Const ConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=DATA.mdb;Persist Security Info=False"
Private Sub ExitCommand_Click()
Form4.Visible = False
Form2.Visible = True
Unload Form10
End Sub
Private Sub StuNoCommand_Click()
Dim ScoreCount As Integer
Dim strSql As String
Dim i As Integer
Dim flag As Integer
Dim FailName As String
Dim SixToSevenName As String
Dim SevenToEightName As String
Dim EightToNineName As String
Dim NineToTenName As String
Dim FailCount As Integer
Dim SixToSevenCount As Integer
Dim SevenToEightCount As Integer
Dim EightToNineCount As Integer
Dim NineToTenCount As Integer
FailName = ""
SixToSevenName = ""
SevenToEightName = ""
EightToNineName = ""
NineToTenName = ""
strCourseName = ""
FailCount = 0
SixToSevenCount = 0
SevenToEightCount = 0
EightToNineCount = 0
NineToTenCount = 0
CountText.Text = ""
i = 0
Set Conn = New ADODB.Connection
Set rs = New ADODB.Recordset
Conn.Open ConnStr
strSql = "select * from 成绩表"
strCourse = CourseText.Text
flag = 0
If strCourse = "高数" Or strCourse = "英语" Or strCourse = "物理" Or strCourse = "计算机" Or strCourse = "C语言" Then
flag = 1
End If
If flag = 1 Then
If Conn.State = 1 Then
rs.Open strSql, Conn, adOpenKeyset, adLockPessimistic
While i < rs.RecordCount
If strCourse = "高数" Then
If rs.Fields(3) < 60 Then
FailName = FailName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(3) & vbCrLf
FailCount = FailCount + 1
ElseIf rs.Fields(3) >= 60 And rs.Fields(3) < 70 Then
SixToSevenName = SixToSevenName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(3) & vbCrLf
SixToSevenCount = SixToSevenCount + 1
ElseIf rs.Fields(3) >= 70 And rs.Fields(3) < 80 Then
SevenToEightName = SevenToEightName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(3) & vbCrLf
SevenToEightCount = SevenToEightCount + 1
ElseIf rs.Fields(3) >= 80 And rs.Fields(3) < 90 Then
EightToNineName = EightToNineName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(3) & vbCrLf
EightToNineCount = EightToNineCount + 1
ElseIf rs.Fields(3) >= 90 And rs.Fields(3) <= 100 Then
NineToTenName = NineToTenName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(3) & vbCrLf
NineToTenCount = NineToTenCount + 1
End If
ElseIf strCourse = "英语" Then
If rs.Fields(4) < 60 Then
FailName = FailName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(4) & vbCrLf
FailCount = FailCount + 1
ElseIf rs.Fields(4) >= 60 And rs.Fields(4) < 70 Then
SixToSevenName = SixToSevenName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(4) & vbCrLf
SixToSevenCount = SixToSevenCount + 1
ElseIf rs.Fields(4) >= 70 And rs.Fields(4) < 80 Then
SevenToEightName = SevenToEightName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(4) & vbCrLf
SevenToEightCount = SevenToEightCount + 1
ElseIf rs.Fields(4) >= 80 And rs.Fields(4) < 90 Then
EightToNineName = EightToNineName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(4) & vbCrLf
EightToNineCount = EightToNineCount + 1
ElseIf rs.Fields(4) >= 90 And rs.Fields(4) <= 100 Then
NineToTenName = NineToTenName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(4) & vbCrLf
NineToTenCount = NineToTenCount + 1
End If
ElseIf strCourse = "物理" Then
If rs.Fields(5) < 60 Then
FailName = FailName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(5) & vbCrLf
FailCount = FailCount + 1
ElseIf rs.Fields(5) >= 60 And rs.Fields(5) < 70 Then
SixToSevenName = SixToSevenName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(5) & vbCrLf
SixToSevenCount = SixToSevenCount + 1
ElseIf rs.Fields(5) >= 70 And rs.Fields(5) < 80 Then
SevenToEightName = SevenToEightName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(5) & vbCrLf
SevenToEightCount = SevenToEightCount + 1
ElseIf rs.Fields(5) >= 80 And rs.Fields(5) < 90 Then
EightToNineName = EightToNineName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(5) & vbCrLf
EightToNineCount = EightToNineCount + 1
ElseIf rs.Fields(5) >= 90 And rs.Fields(5) <= 100 Then
NineToTenName = NineToTenName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(5) & vbCrLf
NineToTenCount = NineToTenCount + 1
End If
ElseIf strCourse = "计算机" Then
If rs.Fields(6) < 60 Then
FailName = FailName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(6) & vbCrLf
FailCount = FailCount + 1
ElseIf rs.Fields(6) >= 60 And rs.Fields(6) < 70 Then
SixToSevenName = SixToSevenName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(6) & vbCrLf
SixToSevenCount = SixToSevenCount + 1
ElseIf rs.Fields(6) >= 70 And rs.Fields(6) < 80 Then
SevenToEightName = SevenToEightName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(6) & vbCrLf
SevenToEightCount = SevenToEightCount + 1
ElseIf rs.Fields(6) >= 80 And rs.Fields(6) < 90 Then
EightToNineName = EightToNineName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(6) & vbCrLf
EightToNineCount = EightToNineCount + 1
ElseIf rs.Fields(6) >= 90 And rs.Fields(6) <= 100 Then
NineToTenName = NineToTenName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(6) & vbCrLf
NineToTenCount = NineToTenCount + 1
End If
Else: strCourse = "C语言"
If rs.Fields(7) < 60 Then
FailName = FailName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(7) & vbCrLf
FailCount = FailCount + 1
ElseIf rs.Fields(7) >= 60 And rs.Fields(7) < 70 Then
SixToSevenName = SixToSevenName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(7) & vbCrLf
SixToSevenCount = SixToSevenCount + 1
ElseIf rs.Fields(7) >= 70 And rs.Fields(7) < 80 Then
SevenToEightName = SevenToEightName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(7) & vbCrLf
SevenToEightCount = SevenToEightCount + 1
ElseIf rs.Fields(7) >= 80 And rs.Fields(7) < 90 Then
EightToNineName = EightToNineName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(7) & vbCrLf
EightToNineCount = EightToNineCount + 1
ElseIf rs.Fields(7) >= 90 And rs.Fields(7) <= 100 Then
NineToTenName = NineToTenName & "姓名:" & rs.Fields(2) & " " & "分数:" & rs.Fields(7) & vbCrLf
NineToTenCount = NineToTenCount + 1
End If
End If
rs.MoveNext
i = i + 1
Wend
End If
CountText.Text = CountText.Text & "不及格人数:" & FailCount & vbCrLf
CountText.Text = CountText.Text & FailName & vbCrLf
CountText.Text = CountText.Text & "60-69人数:" & SixToSevenCount & vbCrLf
CountText.Text = CountText.Text & SixToSevenName & vbCrLf
CountText.Text = CountText.Text & "70-79人数:" & SevenToEightCount & vbCrLf
CountText.Text = CountText.Text & SevenToEightName & vbCrLf
CountText.Text = CountText.Text & "80-89人数:" & EightToNineCount & vbCrLf
CountText.Text = CountText.Text & EightToNineName & vbCrLf
CountText.Text = CountText.Text & "90-100人数:" & NineToTenCount & vbCrLf
CountText.Text = CountText.Text & NineToTenName & vbCrLf
rs.Close
Conn.Close
End If
If flag = 0 Then
CountText.Text = "数据库中没有这个课程的成绩记录"
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -