User:Pluke/bubblelist

From Wikibooks, open books for an open world
Jump to: navigation, search
Module Module1
 
    Sub Main()
 
        Dim list As New List(Of Integer)
        Dim randomG As New Random
        For i As Integer = 0 To 10
            list.Add(randomG.Next(0, 1000))
        Next
 
 
 
        Dim swapped As Boolean = True
        Dim temp As Integer
        Do
            swapped = False
 
            For i As Integer = 0 To list.Count - 2
                If list(i) > list(i + 1) Then
                    temp = list(i + 1)
                    list(i + 1) = list(i)
                    list(i) = temp
                    swapped = True
                End If
            Next
            For x = 0 To list.Count - 1
                Console.Write(list(x) & ",")
            Next
            Console.ReadLine()
        Loop Until swapped = False
 
        Console.ReadLine()
    End Sub
 
End Module