VB编程代码,请尽量用比较简单的代码,原谅我这只菜鸟。。。
【提高题】10个同学参加测试,分数为A,B,C,D,E五个等级,如果A计5分,B计4分,以此类推,求这10个同学的平均成绩。【提示】可以设置一个变量做累加器,用Selec...
【提高题】10个同学参加测试,分数为A,B,C,D,E五个等级,如果A计5分,B计4分,以此类推,求这10个同学的平均成绩。
【提示】可以设置一个变量做累加器,用Select Case语句实现 展开
【提示】可以设置一个变量做累加器,用Select Case语句实现 展开
4个回答
展开全部
Private Sub Command1_Click()
Dim strA(9) As String
Dim i, s As Long
s = 0
For i = 0 To 9
strA(i) = InputBox("请输入第" & i + 1 & "位同学成绩!", "提示:(成绩为大写ABCDE)")
If Asc(strA(i)) < 65 Or Asc(strA(i)) > 69 Then
MsgBox "输入有误,成绩只限于大写A、B、C、D、E", vbCritical, "错误"
Exit Sub
End If
Next i
For i = 0 To 9
Select Case strA(i)
Case "A"
s = s + 5
Case "B"
s = s + 4
Case "C"
s = s + 3
Case "D"
s = s + 2
Case "E"
s = s + 1
End Select
Next i
MsgBox "这十位同学的平均成绩是:" & s / 10, , "平均成绩"
End Sub
Dim strA(9) As String
Dim i, s As Long
s = 0
For i = 0 To 9
strA(i) = InputBox("请输入第" & i + 1 & "位同学成绩!", "提示:(成绩为大写ABCDE)")
If Asc(strA(i)) < 65 Or Asc(strA(i)) > 69 Then
MsgBox "输入有误,成绩只限于大写A、B、C、D、E", vbCritical, "错误"
Exit Sub
End If
Next i
For i = 0 To 9
Select Case strA(i)
Case "A"
s = s + 5
Case "B"
s = s + 4
Case "C"
s = s + 3
Case "D"
s = s + 2
Case "E"
s = s + 1
End Select
Next i
MsgBox "这十位同学的平均成绩是:" & s / 10, , "平均成绩"
End Sub
展开全部
Dim a(10) As String '这10个同学的数组你可以自己做
Dim fen As String
Dim i, sum
sum = 0
For i = 0 To 9
fen = a(i)
Select Case fen
Case "A"
sum = sum + 5
Case "B"
sum = sum + 4
Case "C"
sum = sum + 3
Case "D"
sum = sum + 2
Case "E"
sum = sum + 1
End Select
Next i
Dim fen As String
Dim i, sum
sum = 0
For i = 0 To 9
fen = a(i)
Select Case fen
Case "A"
sum = sum + 5
Case "B"
sum = sum + 4
Case "C"
sum = sum + 3
Case "D"
sum = sum + 2
Case "E"
sum = sum + 1
End Select
Next i
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Form_Click()
Dim dj As String
Dim i, s As Long
s = 0
For i = 0 To 9
dj = InputBox("请输入第" & i + 1 & "位同学成绩!", "提示:(成绩为大写ABCDE)")
If Asc(dj) < 65 Or Asc(dj) > 69 Then
MsgBox "输入有误,成绩只限于大写A、B、C、D、E"
Exit Sub
End If
Select Case dj
Case "A"
s = s + 5
Case "B"
s = s + 4
Case "C"
s = s + 3
Case "D"
s = s + 2
Case "E"
s = s + 1
End Select
Next i
MsgBox "这十位同学的平均成绩是:" & s / 10, , "平均成绩"
End Sub
Dim dj As String
Dim i, s As Long
s = 0
For i = 0 To 9
dj = InputBox("请输入第" & i + 1 & "位同学成绩!", "提示:(成绩为大写ABCDE)")
If Asc(dj) < 65 Or Asc(dj) > 69 Then
MsgBox "输入有误,成绩只限于大写A、B、C、D、E"
Exit Sub
End If
Select Case dj
Case "A"
s = s + 5
Case "B"
s = s + 4
Case "C"
s = s + 3
Case "D"
s = s + 2
Case "E"
s = s + 1
End Select
Next i
MsgBox "这十位同学的平均成绩是:" & s / 10, , "平均成绩"
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
说的不太明白
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询