The MsgBox is there to show how it actually goes through the integer array. You can remove it as well!
' A sample of Bubble sort
' Have fun!
Dim i() As Integer = New Integer(4) {2, 5, 3, 1, 4}
Dim t As Boolean = True
While (t)
t = False
For j As Integer = 0 To 3
If i(j) > i(j + 1) Then
Dim _vec As Integer = i(j)
i(j) = i(j + 1)
i(j + 1) = _vec
t = True
'this is only to check the value of i
Dim _result As String = ""
For y As Integer = 0 To 4
_result &= i(y) & ","
Next
MsgBox(_result)
End If
Next
End While
Leave a Reply