vb 取 最大值 最小值
1个回答
展开全部
Private Sub Form_Load()
Dim Max As Double, Min As Double, I As Long, K As Double
On Error Resume Next
K = Val(InputBox("请输入一个数:", "输入", 0))
Max = K
Min = K
For I = 2 To 10
K = Val(InputBox("请输入一个数:", "输入", 0))
If K > Max Then
Max = K
ElseIf K < Min Then
Min = K
End If
Next
MsgBox "最大数为:" & Max & vbCrLf & "最小数为:" & Min, vbOKOnly, "输出"
End Sub
Dim Max As Double, Min As Double, I As Long, K As Double
On Error Resume Next
K = Val(InputBox("请输入一个数:", "输入", 0))
Max = K
Min = K
For I = 2 To 10
K = Val(InputBox("请输入一个数:", "输入", 0))
If K > Max Then
Max = K
ElseIf K < Min Then
Min = K
End If
Next
MsgBox "最大数为:" & Max & vbCrLf & "最小数为:" & Min, vbOKOnly, "输出"
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询