vb中比较3数的大小的编程,要用IF语句.

 我来答
百度网友0b3e655
2010-03-08 · TA获得超过127个赞
知道小有建树答主
回答量:86
采纳率:0%
帮助的人:0
展开全部
Private Sub Command_1Click()
Dim a!,b!c!,w!
a=Val(Text1)
b=Val(Text2)
c=Val(Text3)
If a<b then
w=a
a=b
b=w
End if
If a<c Then
w=a
a=c
c=w
End if
If b<c then
w=b
b=c
c=w
End if
Label4.Caption="从大到搭拆滑知腊小排列御慎为:"&Str(a)&Str(b)&Str(c)
End Sub
绝对正确!
veimi
2010-03-08 · TA获得超过2350个赞
知道大有可为答主
回答量:5720
采纳率:28%
帮助的人:3058万
展开全部
建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

============================================
'10个数比较大小
Option Explicit
Dim a(1 To 10) As Integer
Dim i, j, x As Integer, s As String, b As Boolean

Private Sub Command1_Click()
'产生10个不重复的随机数
s = ""
Randomize
For i = 1 To 10
b = False
x = Int(Rnd * 99 + 1)
Do
For j = 1 To i - 1
If x = a(j) Then b = True: Exit For
Next j
Loop While b = True
a(i) = x
s = s & " " & Str(a(i))
Next i
Print s

End Sub

Private Sub Command2_Click()
'对则盯10分随机数按大小排序
s = "": x = 0
For i = 2 To 10
For j = 1 To i - 1
If a(i) > a(j) Then x = a(i): a(i) = a(j): a(j) = x
Next j
Next i
For i = 1 To 10
s = s & " " & Str(a(i))
Next i
Print s
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式