第1个回答 2008-03-25
Private Sub Command1_Click()
Dim num1 As Integer
Dim num2 As Integer
Dim num3 As Integer
num1 = Val(Text1.Text)
num2 = Val(Text2.Text)
num3 = Val(Text3.Text)
Dim temp As Integer
If num1 > num2 Then
temp = num1
num1 = num2
num2 = temp
End If
If num1 > num3 Then
temp = num1
num1 = num3
num3 = temp
End If
If num2 > num3 Then
temp = num2
num2 = num3
num3 = temp
End If
Label4.Caption = "First is : " & num1 & " Second is : " & num2 & " Third is :" & num3
End Sub
第2个回答 2008-03-26
三个数,冒泡要两趟
第一趟最小数放在最前,要两次判断
第二趟次小数放在次前,要一次判断
Private Sub Form_Click()
If Val(Text2.Text) > Val(Text3.Text) Then
p = Text2.Text
Text2.Text = Text3.Text
Text3.Text = p
End If
If Val(Text1.Text) > Val(Text2.Text) Then
p = Text1.Text
Text1.Text = Text2.Text
Text2.Text = p
End If
If Val(Text2.Text) > Val(Text3.Text) Then
p = Text2.Text
Text2.Text = Text3.Text
Text3.Text = p
End If
End Sub
第3个回答 2008-03-25
用冒泡法,这个方法在一般的教材上应该都有。
我的qq是905221006,+我我给你讲。