vb利用静态数组实现50个成绩输入并计算所有成绩的综合和平均分

2020-05-05 教育 113阅读
Private Sub Command1_Click()
Dim i As Integer
Dim sum, scores(50) As Double
sum = 0
For i = 1 To 50
scores(i) = InputBox("输入第" & i & "数字:", "提示")
If scores(i) > 100 Or scores(i) < 0 Then
MsgBox "成绩必须在0到100之间!"
scores(i) = InputBox("输入第" & i & "数字:", "提示")
Else
sum = sum + scores(i)
End If
Next i
Text1.Text = Format(sum, "0.00")
Text2.Text = Format(sum * 1# / 50, "0.00")
End Sub
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com