vb三个数字大小比较编程

来源:百度知道 编辑:UC知道 时间:2024/06/23 00:54:35
x,y,z三个数,按从大到小的次序排列代码编程,急!

Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim temp As Integer
Dim array() As Integer
array = New Integer() {a, b, c}
For i As Integer = 0 To 2
For j As Integer = i + 1 To 2
If array(i) < array(j) Then
temp = array(i)
array(i) = array(j)
array(j) = temp
End If
Next
Next

Private Sub Command1_Click()
x = 3: y = 1: z = 5
Print x, y, z
If x < y Then t = x: x = y: y = t
If x < z Then t = x: x = z: z = t
If y < z Then t = y: y = z: z = t
Print x, y, z
End Sub

Private Sub Form_Click()
Dim x%, y%, z%
x = Val(InputBox("x: "))
y = Val(InputBox("y: "))
z = Val(InputBox("z: "))
If x > y Then
t = x
x = y
y = t