VB.NET example-bubble sort algorithm


Bubble sort algorithm


This is VB example code for the bubble sort.

Module Module1

    Sub Main()

        Dim arr() As Integer = New Integer() {30, 12, 32, 34, 45, 90}

        'sort the array using bubble sort

        bubbleSort(arr, arr.Length)

        'output the sorted array

        Dim i As Integer

        For i = 0 To arr.Length - 1

            Console.WriteLine(arr(i))

        Next

        Console.ReadLine() 'wait for keypress

    End Sub

 

    Sub bubbleSort(ByVal dataset() As Integer, ByVal n As Integer)

        Dim i, j As Integer

        For i = 0 To n Step 1

            For j = n - 1 To i + 1 Step -1

                If (dataset(j) < dataset(j - 1)) Then

 

                    Dim temp As Integer = dataset(j)

                    dataset(j) = dataset(j - 1)

                    dataset(j - 1) = temp

 

                End If

 

            Next

        Next

    End Sub

End Module


Comments

chery comment

 chery

oke cool


2018-05-17
chery comment

 chery

oke cool


2018-05-17
Darth Vader comment

 Darth Vader

I couldn't have! She was alive! I felt her! She was alive! It's impossible! Nooooooooooo!!!


2018-04-25
Darth Sidious comment

 Darth Sidious

I'm afraid she died. ... it seems in your anger, you killed her.


2018-04-25
Darth Vader comment

 Darth Vader

Yes, My Master, where is Padme? Is she safe, is she all right?


2018-04-25
Darth Sidious comment

 Darth Sidious

Lord Vader, can you hear me?


2018-04-25
Anakin comment

 Anakin

I hate you!


2018-04-25
ObiWan comment

 ObiWan

*Picks up Anakin's light saber and begins to walk away*


2018-04-25
Anakin comment

 Anakin

ARGHHHH *Jumps at ObiWan*


2018-04-25
ObiWan comment

 ObiWan

You were the Chosen One! You were supposed to destroy the Sith, not join them. You were supposed to bring balance to the force, not leave it in darkness.


2018-04-25
ObiWan comment

 ObiWan

You were my brother, Anakin. I loved you.


2018-04-25
Anakin comment

 Anakin

Well from my point of view the Jedi are evil!


2018-04-25
ObiWan comment

 ObiWan

B0i


2018-04-25
ObiWan comment

 ObiWan

Don't try it!


2018-04-25
Anakin comment

 Anakin

You underestimate my power!


2018-04-25
ObiWan comment

 ObiWan

It's over Anakin, i have the high ground.


2018-04-25
Dani Baijan comment

 Dani Baijan

I love Currys PC World and Uncle Bens


2018-04-18
erjol balla comment

 erjol balla

albaniaaaaaaaaaaaaaaaaaaaaaaaaaaaa
chevkioek ballaaaaaaaaaaaaaaaaaaa


2018-04-18
Jack Anscombe comment

 Jack Anscombe

I love tomatoes


2018-04-18
benjamin smith comment

 benjamin smith

legend thanks love you


2017-11-07
de nyerez comment

 de nyerez

thanks but can you sort in the sub main only without using sub routines


2017-09-17
narissa comment

 narissa

ty youre a saviour


2017-08-13
Wow comment

 Wow

no way


2017-05-18
Darth Plagueis The Wise comment

 Darth Plagueis The Wise

Beam me up Scotty!
-Chandler from friends


2017-05-18
Boglin comment

 Boglin

Did you ever hear the tragedy of Darth Plagueis The Wise? I thought not. It’s not a story the Jedi would tell you. It’s a Sith legend. Darth Plagueis was a Dark Lord of the Sith, so powerful and so wise he could use the Force to influence the midichlorians to create life… He had such a knowledge of the dark side that he could even keep the ones he cared about from dying. The dark side of the Force is a pathway to many abilities some consider to be unnatural. He became so powerful… the only thing he was afraid of was losing his power, which eventually, of course, he did. Unfortunately, he taught his apprentice everything he knew, then his apprentice killed him in his sleep. Ironic. He could save others from death, but not himself.


2017-03-13
as comment

 as

ad


2017-02-15
royvin comment

 royvin

royvin


2017-02-09
fuqtry comment

 fuqtry

sadasdsad
a
dsa
ds
ad
sadsa
ad


2015-11-14
CAPTCHA image




This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.