输入三个整数a,b,c设计一个算法使得输入的三个整数按从小到大的次序分别存放在变量a,b,c中.

问题描述:

输入三个整数a,b,c设计一个算法使得输入的三个整数按从小到大的次序分别存放在变量a,b,c中.
要求:运行时单击窗体按序弹出三个inputbox输入框,计算后直接在窗体上打印出a,b,c三个变量的值

Sub test()
Dim arr(1 To 3) As Integer
Dim i As Integer
Dim a As Integer,b As Integer,c As Integer
Dim x As String
For i = 1 To 3
arr(i) = InputBox("请输入第 " & i & " 个值:")
Next i
a = Application.WorksheetFunction.Small(arr,1)
b = Application.WorksheetFunction.Small(arr,2)
c = Application.WorksheetFunction.Small(arr,3)
x = "a=" & a & vbCrLf & "b=" & b & vbCrLf & "c=" & c
MsgBox x
End Sub