在VB中使用窗体CLICK事件,编写程序:任意输入10个数(用INPUT函数),求它们的最大值,最小值和平均值。
1个回答
展开全部
Private Sub Form_Click()
Dim i As Integer
Dim s As Single
Dim min As Single
Dim max As Single
Dim m As Single
s = 0
For i = 1 To 10
m = Val(InputBox(""))
If i = 1 Then
max = m
min = m
Else
If max < m Then max = m
If min > m Then min = m
End If
s = s + m
Next i
Print "最大值是:" & max
Print "最小值是:" & min
Print "平均值是:" & s / 10
End Sub
Dim i As Integer
Dim s As Single
Dim min As Single
Dim max As Single
Dim m As Single
s = 0
For i = 1 To 10
m = Val(InputBox(""))
If i = 1 Then
max = m
min = m
Else
If max < m Then max = m
If min > m Then min = m
End If
s = s + m
Next i
Print "最大值是:" & max
Print "最小值是:" & min
Print "平均值是:" & s / 10
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询