vb三值排序

来源:百度知道 编辑:UC知道 时间:2024/06/03 04:56:55
用IF语句及其嵌套实现3个数字的排序在3个文本框中输入数字,单击[排序]按钮后按从大到小排列。单击[退出]按钮出现提示对话框。(MsgBox实现)
MsgBox 确实想退出吗 是 否

Private Sub Command1_Click()
Dim A As Long, B As Long, C As Long
A = Text1.Text
B = Text2.Text
C = Text3.Text

If A > B And A > C And B > C Then Text1.Text = A: Text2.Text = B: Text3.Text = C
If A > B And A > C And C > B Then Text1.Text = A: Text2.Text = C: Text3.Text = B
If B > A And B > C And A > C Then Text1.Text = B: Text2.Text = A: Text3.Text = C
If B > A And B > C And C > A Then Text1.Text = B: Text2.Text = C: Text3.Text = A
If C > A And C > B And A > B Then Text1.Text = C: Text2.Text = A: Text3.Text = B
If C > A And C > B And B > A Then Text1.Text = C: Text2.Text = B: Text3.Text = A
End Sub

Private Sub Command2_Click()
MsgBox "确实想退出吗?", 4, "提示"
Unload Me
End Sub

Private Sub Form_Load()
Command1.Caption = "排序"
Command2.Caption = "退出"
End Sub

Option Explicit