图1:
是前面的数字比较小,,算正常。
图2:
后面或第一个,大,就不行了。
Private Sub Command1_Click()
Dim l(6) As Integer
Dim a, b, c, d, e, f As Integer
Dim i As Integer
Dim k As Integer
Dim t As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
d = Val(Text4.Text)
e = Val(Text5.Text)
f = Val(Text6.Text)
For i = 1 To 1
l(i) = a
Next
For i = 2 To 2
l(i) = b
Next
For i = 3 To 3
l(i) = c
Next
For i = 4 To 4
l(i) = d
Next
For i = 5 To 5
l(i) = e
Next
For i = 6 To 6
l(i) = f
Next
For i = 2 To 6
For k = 6 To 2 Step -1
If l(k) < l(k - 1) Then
t = l(k)
l(k) = l(k - 1)
l(k - 1) = t
Else
Exit For
End If
Next
Next
Text7.Text = l(1)
Text8.Text = l(2)
Text9.Text = l(3)
Text10.Text = l(4)
Text11.Text = l(5)
Text12.Text = l(6)
End Sub
这是上面的代码。
本人只是刚学习到排序,想试试而已。。
用INPUTBOX这个没什么问题。但用TEXT那就不行,,请会的朋友告诉我一声。
谢谢~