vb中三个数比较大小
来源:百度知道 编辑:UC知道 时间:2024/06/22 01:32:47
a、b、c三个整数,按从小到大的顺序
建Command1,代码如下。
================
Option Explicit
Private Sub Command1_Click()
Dim a As Integer, b As Integer, c As Integer, t As Integer
a = Val(InputBox("a=?"))
b = Val(InputBox("b=?"))
c = Val(InputBox("c=?"))
If a > b Then t = b: b = a: a = t
If a > c Then t = c: c = a: a = t
If b > c Then t = c: c = b: b = t
Print "从小到大:"; a; b; c
End Sub
冒泡排序,
for i = 1 to 3
for j = 1 to i
if a>b then
d=a
a=b
b=d
endif
next
next