Dim Scores(1 To 10) As Single
Call InputScore(Scores)
Call PrintScore(Scores)
Call AboveAverage(Scores)
Call ScoreSort(Scores)
Call PrintScore(Scores)
Call FindMaxMin(Scores)
End Sub
Private Sub InputScore(sngScores() As Single)
Dim i As Single
For i = LBound(sngScores) To UBound(sngScores)
sngScores(i) = InputBox("请输入第" & i & "名学生高考成绩:", "高考成绩管理系统", 600)
Next i
End Sub
Private Sub PrintScore(sngScores() As Single)
Dim i As Integer
Load Form1
Form1.Show
For i = LBound(sngScores) To UBound(sngScores)
Form1.Print sngScores(i)
Next i
Form1.Print
End Sub
Private Sub ScoreSort(sngScores() As Single)
Dim i As Integer, j As Integer, t As Single
For i = LBound(sngScores) To UBound(sngScores) - 1
For j = i + 1 To UBound(sngScores)
If sngScores(j) > sngScores(i) Then
t = sngScores(i)
sngScores(i) = sngScores(j)
sngScores(j) = t
End If
Next j
Next i
End Sub
Private Sub AboveAverage(sngScores() As Single)
Dim i As Integer, k As Integer, sngSum As Single, sngAverage As Single
For i = LBound(sngScores) To UBound(sngScores)
sngSum = sngSum + sngScores(i)
Next i
sngAverage = sngSum / UBound(sngScores)
For i = LBound(sngScores) To UBound(sngScores)
If sngScores(i) > sngAverage Then
k = k + 1
End If
Next i
Form1.Print "平均值为:" sngAverage,
Form1.Print "高于平均值的人数为:" k
End Sub
Private Sub FindMaxMin(sngScores() As Single)
Dim i As Integer, sngMax As Single, sngMin As Single
sngMax = sngScores(LBound(sngScores))
sngMin = sngScores(LBound(sngScores))
For i = LBound(sngScores) + 1 To UBound(sngScores)
If sngScores(i) > sngMax Then sngMax = sngScores(i)
If sngScores(i) < sngMin Then sngMin = sngScores(i)
Next i
Form1.Print "最高分为:" sngMax, "最低分为:" sngMin
End Sub
Private Sub Command2_Click()With rs2
.Fields("第一单元") = Text3.Text
.Update
End With
rs2.MoveNext
Text1.Text = rs2.Fields("学生编号")
Text2.Text = rs2.Fields("学生姓名")
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)