Bubble sorting and Bubble Sorting
Imports System. Threading
Module Module1
Sub Main ()
Dim int_array (9) As Integer
Dim rnd As New Random
'Fill in the array element
For I As Integer = 0 To int_array.Length-1
Int_array (I) = rnd. Next (0,100)
Console. Write (int_array (I )&",")
Thread. Sleep (150)
Next
Console. WriteLine (vbCrLf &"-------------------------------")
Dim x As Integer
X = 2
Do
For I As Integer = 0 To int_array.Length-x
If (int_array (I)> int_array (I + 1) Then
Exchange (int_array (I), int_array (I + 1 ))
End If
Next I
X + = 1
'Output the result to the console
For j As Integer = 0 To int_array.Length-1
Console. Write (int_array (j )&",")
Next j
Console. WriteLine ()
Loop While (x <= int_array.Length)
Console. ReadKey ()
End Sub
'SWAp Value
Public Sub Exchange (ByRef val1 As Integer, ByRef val2 As Integer)
Dim temp As Integer
Temp = val1
Val1 = val2
Val2 = temp
End Sub
End Module