2个回答
展开全部
Private Sub Command1_Click()
Dim myStr As String
Dim s As Double
Dim n As Long
n = 0
s = 0
Do
myStr = InputBox("请输入一个数,当输入AAA时结束输入并计算全部数的平均值。")
If UCase(myStr) <> "AAA" Then
If IsNumeric(myStr) Then
s = s + Val(myStr)
n = n + 1
Else
MsgBox "请输入数字."
End If
Else
MsgBox "以上" & Str(n) & "个数的平均值为:" & Str(s / n)
Exit Do
End If
Loop
End Sub
Dim myStr As String
Dim s As Double
Dim n As Long
n = 0
s = 0
Do
myStr = InputBox("请输入一个数,当输入AAA时结束输入并计算全部数的平均值。")
If UCase(myStr) <> "AAA" Then
If IsNumeric(myStr) Then
s = s + Val(myStr)
n = n + 1
Else
MsgBox "请输入数字."
End If
Else
MsgBox "以上" & Str(n) & "个数的平均值为:" & Str(s / n)
Exit Do
End If
Loop
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询