3个数比大小

时间:2022-09-02 09:03:39

Dim a(3) As Double, i As Integer, t As Integer

    For i = 1 To 3

        a(i) =InputBox("请输入第" &i & "个数")

    Next i

    If a(1) <a(2) Then change2num a(1), a(2)

    If a(1) <a(3) Then change2num a(1), a(3)

    If a(2) <a(3) Then change2num a(2), a(3)

    MsgBox "排序后的输出是:" & vbCrLf & a(1) & "" & a(2) & " " & a(3)

    End

End Sub

Function change2num(x As Double, y As Double)

    Dim t As Double

    t = x

    x = y

    y = t