VB三数比大小

来源:百度知道 编辑:UC知道 时间:2024/05/29 17:33:39
Dim a, b, c
Private Sub Command1_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
If a > b > c Then
Label1.Caption = "a"
end if

If c > a > b Then
Label1.Caption = "c"
End If

If b > c > a Then
Label1.Caption = "b"
End If
哪不对吗,如果不对,正确的(完整的过程)是什么

Private Sub Command1_Click()
Dim a%, b%, c%
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
If a >= b And a >= c Then
Label1.Caption = a
End If

If c >= a And c >= b Then
Label1.Caption = c
End If

If b >= c And b >= a Then
Label1.Caption = b
End If
End Sub
这样做才对!
Label1.Caption = "a" a不能用引号

a > b > c
不能这样写!
这样
a>b and a>c
c>a and c>b
b>a and b>c

不能连起来写,一楼正解

很有问题.设a=8,b=5,c=3,则
if a>b>c Then
Label1.Caption = "a"
end if
执行后,Label1并不显示"a".这是因为先计算a>b,其值为-1,-1不大于3.即a>b>c的值为false.
参考程序:
If a > b Then
If b > c Then
Print a
End If
Else
If b < c Then
Print c
Else
If b > c Then
Print b
End If
End If
End If