0% found this document useful (0 votes)
8 views1 page

Bubble Sort Code VB

This document contains a VB.NET program that implements the Bubble Sort algorithm. It initializes an array of integers, sorts it using the Bubble Sort method, and displays both the original and sorted arrays. The program concludes by prompting the user to press ENTER to exit.

Uploaded by

cinimon6464
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Bubble Sort Code VB

This document contains a VB.NET program that implements the Bubble Sort algorithm. It initializes an array of integers, sorts it using the Bubble Sort method, and displays both the original and sorted arrays. The program concludes by prompting the user to press ENTER to exit.

Uploaded by

cinimon6464
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

VB.

NET Ready-to-Run Bubble Sort Program

Sub Main()

Dim Data() As Integer = {12, 5, 9, 22, 31, 4, 18, 27, 6, 14}

[Link]("Original array:")
DisplayArray(Data)

Call BubbleSort(Data)

[Link]("Sorted array (Bubble Sort):")


DisplayArray(Data)

[Link]()
[Link]("Press ENTER to exit...")
[Link]()

End Sub

Sub BubbleSort(ByRef A() As Integer)

Dim N As Integer = [Link]


Dim Pass As Integer
Dim Index As Integer
Dim Temp As Integer

For Pass = 1 To N - 1
For Index = 0 To N - Pass - 1

If A(Index) > A(Index + 1) Then


Temp = A(Index)
A(Index) = A(Index + 1)
A(Index + 1) = Temp
End If

Next Index
Next Pass

End Sub

Sub DisplayArray(ByVal A() As Integer)

Dim I As Integer

For I = 0 To [Link] - 1
[Link](A(I) & " ")
Next I

[Link]()

End Sub

You might also like