1个回答
展开全部
Dim n As Integer, StuName() As String * 4, Math() As Single, English() As Single
Dim MathSum As Single, EnglishSum As Single
Private Sub Command1_Click()
n = InputBox("请输入人数:", "学生成绩录入")
End Sub
Private Sub Command2_Click()
ReDim StuName(1 To n)
For i = 1 To n
StuName(i) = InputBox("请输入第" & i & "位(共" & n & "位)学生姓名:", "输入姓名")
Next i
End Sub
Private Sub Command3_Click()
ReDim Math(1 To n)
For i = 1 To n
Math(i) = InputBox("请输入第" & i & "位(共" & n & "位)学生高数成绩:", "输入高数成绩")
MathSum = MathSum + Math(i)
Next i
End Sub
Private Sub Command4_Click()
ReDim English(1 To n)
For i = 1 To n
English(i) = InputBox("请输入第" & i & "位(共" & n & "位)学生英语成绩:", "输入英语成绩")
EnglishSum = EnglishSum + English(i)
Next i
End Sub
Private Sub Command5_Click()
List1.AddItem ""
List1.AddItem "--------------------------------------------------------------"
List1.AddItem "姓 名" + Space(4) + "高数" + Space(4) + "英语"
For i = 1 To n
List1.AddItem "-----------------------------------------------------------"
List1.AddItem StuName(i) + Space(4) + CStr(Math(i)) + Space(6) + CStr(English(i))
Next i
List1.AddItem "----------------------------------------------------------"
List1.AddItem "平均成绩" + Space(2) + CStr(Format(MathSum / n, "0.00")) + Space(2) + CStr(Format(EnglishSum / n, "0.00"))
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询