⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 a成绩统计.frm

📁 在线考试系统。用vb编写
💻 FRM
📖 第 1 页 / 共 2 页
字号:
            Left            =   1320
            TabIndex        =   10
            Top             =   1680
            Width           =   1215
         End
         Begin VB.Label Label2 
            Alignment       =   2  'Center
            BorderStyle     =   1  'Fixed Single
            Caption         =   "Label2"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   9.75
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FF0000&
            Height          =   375
            Index           =   1
            Left            =   4680
            TabIndex        =   9
            Top             =   240
            Width           =   1215
         End
         Begin VB.Label Label2 
            Alignment       =   2  'Center
            BorderStyle     =   1  'Fixed Single
            Caption         =   "Label2"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   9.75
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FF0000&
            Height          =   375
            Index           =   0
            Left            =   1320
            TabIndex        =   8
            Top             =   240
            Width           =   1215
         End
         Begin VB.Label Label1 
            Caption         =   "平均分:"
            Height          =   255
            Index           =   2
            Left            =   600
            TabIndex        =   7
            Top             =   1800
            Width           =   735
         End
         Begin VB.Label Label1 
            Caption         =   "最低分:"
            Height          =   255
            Index           =   1
            Left            =   3960
            TabIndex        =   6
            Top             =   360
            Width           =   735
         End
         Begin VB.Label Label1 
            Caption         =   "最高分:"
            Height          =   255
            Index           =   0
            Left            =   600
            TabIndex        =   5
            Top             =   360
            Width           =   735
         End
      End
      Begin VB.CommandButton CmdExit 
         BackColor       =   &H00C0C0C0&
         Caption         =   "退出"
         Height          =   360
         Left            =   4680
         Style           =   1  'Graphical
         TabIndex        =   3
         Top             =   360
         Width           =   800
      End
      Begin VB.ComboBox CboQuery 
         Height          =   315
         Left            =   1080
         TabIndex        =   1
         Top             =   360
         Width           =   2055
      End
      Begin VB.Label Label8 
         Caption         =   "选择考试:"
         Height          =   255
         Index           =   0
         Left            =   240
         TabIndex        =   2
         Top             =   360
         Width           =   975
      End
   End
   Begin MSChart20Lib.MSChart MSChart1 
      Height          =   3495
      Left            =   120
      OleObjectBlob   =   "A成绩统计.frx":0000
      TabIndex        =   23
      Top             =   0
      Width           =   6375
   End
End
Attribute VB_Name = "A成绩统计"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim rs As ADODB.Recordset
Dim SQL As String
Dim msg As String
Dim Index As Integer
Private Sub Form_Load()
    '初始化考试代码
    SQL = "Select distinct 考试代码 from 成绩信息表 where 试卷状态='已阅' order by 考试代码"
    Set rs = SelectSQL(SQL, msg)
    If rs.EOF = True Then
        MsgBox "现在还没有成绩信息"
        Exit Sub
    Else
        Do Until rs.EOF
            '添加到ComboBox列表
            CboQuery.AddItem (rs.Fields("考试代码"))
            rs.MoveNext                         '指向下一条记录
        Loop
        CboQuery.listindex = 0                  '默认ComboBox
    End If
    rs.Close
End Sub
Private Sub CboQuery_Click()
'成绩统计操作
    Dim record As Double
    Dim index1 As Integer
    Dim SS(1 To 4, 1 To 2)
    Dim Number(1 To 4) As Integer               '保存各个等级分数的人数
    Dim chart(1 To 4) As String                 '保存图表的列名
    Dim sum As Double                           '保存所有参加考试的人总分数
    Dim stu As Integer                           '保存参加考试的人数
    '初始化数组
    For Index = 1 To 4
        Number(Index) = 0
    Next Index
    '为图表列值赋值
    chart(1) = "60分以下人数"
    chart(2) = "60~75分人数"
    chart(3) = "75~90分人数"
    chart(4) = "90分以上人数"
    '为变量赋初值
    sum = 0
    stu = 0
    '查询成绩信息
    SQL = " Select * from 成绩信息表 where 考试代码='" & Trim(CboQuery.Text) & "'"
    Set rs = SelectSQL(SQL, msg)
    If rs.EOF = True Then
        MsgBox "信息出错", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    Else
        '进行分数段统计
        Do Until rs.EOF
            record = rs.Fields("总分")                  '小于60分的人数
            If record < 60 Then
                Number(1) = Number(1) + 1
            ElseIf record >= 60 And record < 75 Then    '分数在60到75之间的人数
                Number(2) = Number(2) + 1
            ElseIf record >= 75 And record < 90 Then    '分数在75到90之间的人数
                Number(3) = Number(3) + 1
            ElseIf record > 90 Then                     '大于90分的人数
                Number(4) = Number(4) + 1
            End If
            sum = sum + record                  '统计所有参加考试的人总分数
            stu = stu + 1                       '统计参加考试的人数
            rs.MoveNext
        Loop
        '把各个等级分数的人数赋值给Label
        For Index = 0 To 3
            Label3(Index) = str(Number(Index + 1)) & "  个"
        Next Index
        '计算及格率并赋值给Label
        Label2(9).Caption = Format(str((Number(2) + Number(3) + Number(4)) / stu), "00.%")
        '计算平均分并赋值给Label
        Label2(2).Caption = Format(str(sum / stu), "00.00") & "  分"
        '计算参加考试的人数并赋值给Label
        Label2(3).Caption = str(stu) & "  个"
    End If
    '查询最高分
    SQL = " Select max(总分) from 成绩信息表 where 考试代码='" & Trim(CboQuery.Text) & "'"
    Set rs = SelectSQL(SQL, msg)
    Label2(0).Caption = rs.Fields(0) & "  分"
    '查询最低分
    SQL = " Select min(总分) from 成绩信息表 where 考试代码='" & Trim(CboQuery.Text) & "'"
    Set rs = SelectSQL(SQL, msg)
    Label2(1).Caption = rs.Fields(0) & "  分"
    '绘制图表
    For Index = 1 To 4
        SS(Index, 1) = chart(Index)
        For index1 = 2 To 2
            SS(Index, index1) = Number(Index)
        Next index1
    Next Index
    MSChart1.ChartData = SS
End Sub
Private Sub CmdExit_Click()
'退出操作
    A教师阅卷管理.Enabled = True
    Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
'退出操作
    A教师阅卷管理.Enabled = True
    Unload Me
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -