VB排序问题
Option Explicit
Option Base 1
Dim a(100) As Single
Dim i As Single
Private Sub Command1_Click()
Open "C:\Users\Administrator\Desktop\123.txt" For Input As #1
For i = 1 To 100
Input #1, a(i)
Text1 = Text1 & a(i) & Space(5)
Next i
Close #1
End Sub
Private Sub Command2_Click()
Dim j As Single, t As Single
Text1 = ""
For i = 1 To 100
For j = 1 To 100 - i
If a(j) > a(j + 1) Then
t = a(j)
a(j) = a(j + 1)
a(j + 1) = a(j)
End If
Next j
Next i
For i = 1 To 100
Text1 = Text1 & a(i) & Space(5)
Next i
End Sub
为什么最后都显示“1” vb 排序
[解决办法]
t = a(j)
a(j) = a(j + 1)
a(j + 1) = t