(VB小编程)输入三个数,按照从大到小的顺序排序输出

有三个文本框,一个输一个数,然后点击command键在label上显示结果!

Private Sub Form_Load()
Dim x As Integer, y As Integer, z As Integer
Dim diyige As Integer
Dim dierge As String, disange As String, disige As String
diyige = InputBox("请输入第一个数据:", "数据输入窗口")
dierge = InputBox("请输入第二个数据", "数据输入窗口")
disange = InputBox("请输入第三个数据", "数据输入窗口")
x = Val(diyige)
y = Val(dierge)
z = Val(disange)
If x > y And y > z Then
Print z, y, x
ElseIf y > z And z > x Then
Print x, z, y
ElseIf z > x And x > y Then
Print y, x, z
End If
Print "你输入的数据按从小到大的顺序是:"
End Sub
温馨提示:答案为网友推荐,仅供参考
第1个回答  2008-05-03
三个文本框 一个标签框 一个command按钮 粘贴进去就可以用
Private Sub Command1_Click()
a = Val(Text1)
b = Val(Text2)
c = Val(Text3)
If a > b And b > c Then
Label1.Caption = a & ">" & b & ">" & c
ElseIf a > c And c > b Then
Label1.Caption = a & ">" & c & ">" & b
ElseIf b > a And a > c Then
Label1.Caption = b & ">" & a & ">" & c
ElseIf b > c And c > a Then
Label1.Caption = b & ">" & c & ">" & a
ElseIf c > b And b > a Then
Label1.Caption = c & ">" & b & ">" & a
ElseIf c > a And a > b Then
Label1.Caption = c & ">" & a & ">" & b
Else
Label1.Caption = "有相等数存在请重新输入"
End If
End Sub
第2个回答  推荐于2018-02-26
Private Sub Command1_Click()
Dim a, b, c, t
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
If a < b Then
t = a
a = b
b = t
End If
If c > b Then
If c > a Then
Label1.Caption = c & ">" & a & ">" & b
Else
Label1.Caption = a & ">" & c & ">" & b
End If
Else
Label1.Caption = a & ">" & b & ">" & c
End If
End Sub本回答被提问者和网友采纳
第3个回答  2016-01-05
#include<iostream>
using namespace std;
int main()
{
int a,b,c,t;
cin>>a>>b>>c;
if(a<b)
{
t=a;a=b;b=t;
}
if(a<c)
{
t=a;a=c;c=t;
}
if(b<c)
{
t=b;b=c;c=t;
}
cout<<a<<" "<<b<<" "<<c<<endl;
return 0;
}
相似回答