【发布时间】:2014-07-20 19:56:20
【问题描述】:
Private Sub bttSort_Click(sender As Object, e As EventArgs) Handles bttSort.Click
DataView1.Rows.Clear()
Dim i As Integer
Dim j As Integer
Dim temp As Integer
For i = 0 To list1.Length - 1
For j = (i + 1) To list1.Length - 1
If list1(i) > list1(j) Then
temp = list1(i)
list1(i) = list1(j)
list1(j) = temp
End If
Next
Next
DataView1.Rows.Clear()
For m As Integer = 0 To list1.Length - 1
DataView1.Rows.Add(list1(m))
Next
End Sub
我输入了一个字符串(1,3,5,6,7,113,23,62) 运行上面的代码后,输出应该排序为(1, 3, 5, 6, 7, 23, 62, 113 )。但我的输出是 (1, 113, 23, 3, 5, 6, 62, 7)。 我不知道,希望有人可以帮助我。 谢谢。
【问题讨论】:
标签: arrays vb.net string loops visual-studio-2012