Current location: Hot Scripts Forums » Programming Languages » Windows .NET Programming » Bubble sort visualisation


Bubble sort visualisation

Reply
  #1 (permalink)  
Old 08-16-04, 08:10 PM
Just3ala2 Just3ala2 is offline
New Member
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Bubble sort visualisation

hi to all
this is my code
but it doesn't work
u all know the bubble sort
i needed to visualise it on vb.net
i used a group of columns to display the number weight and a group of numeric updowns for the input
i have two buttons, draw and sort
the draw works fine but the problem is in the sort part
here is the full code
************************************************** *******

Private Sub BubbleSort_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Function bubbleSort() As Integer

Dim incounter As Integer = 0
Dim outcounter As Integer = 0
For outcounter = 0 To 9
For incounter = 0 To 8
If grpValues.Controls(incounter).Text > grpValues.Controls((incounter + 1)).Text Then
swap(incounter, (incounter + 1))
End If
Next
Next
Return 0
End Function

Private Sub btnDraw_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDraw.Click
Pic1.Height = Convert.ToInt16(nud1.Value) * 3
Pic2.Height = Convert.ToInt16(nud2.Value) * 3
Pic3.Height = Convert.ToInt16(nud3.Value) * 3
Pic4.Height = Convert.ToInt16(nud4.Value) * 3
Pic5.Height = Convert.ToInt16(nud5.Value) * 3
Pic6.Height = Convert.ToInt16(nud6.Value) * 3
Pic7.Height = Convert.ToInt16(nud7.Value) * 3
Pic8.Height = Convert.ToInt16(nud8.Value) * 3
Pic9.Height = Convert.ToInt16(nud9.Value) * 3
Pic10.Height = Convert.ToInt16(nud10.Value) * 3

End Sub

Private Sub btnSort_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSort.Click

bubbleSort()

End Sub

Private Function swap(ByRef x As Integer, ByRef y As Integer) As Integer

Dim Temploc As Point
Temploc = PicTemp.Location

If x <> y Then
grpVisual.Controls(21).Location = grpVisual.Controls(x).Location
grpVisual.Controls(x).Location() = grpVisual.Controls(y).Location
grpVisual.Controls(y).Location = grpVisual.Controls(21).Location
End If

PicTemp.Location = Temploc

End Function

Private Sub TimerBubbles_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerBubbles.Tick
picBub1.Top -= 4
If picBub1.Top < -20 Then
picBub1.Top = Me.Height - 20
End If
picBub2.Top -= 4
If picBub2.Top < -20 Then
picBub2.Top = Me.Height - 20
End If
picBub3.Top -= 4
If picBub3.Top < -20 Then
picBub3.Top = Me.Height - 20
End If
picBub4.Top -= 4
If picBub4.Top < -20 Then
picBub4.Top = Me.Height - 20
End If

End Sub

************************************************** ********

i'll be grateful for ur help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using VB 6.0 to sort an Excel spreadsheet ChicagoIan Visual Basic 1 07-12-06 07:15 PM
Problem with a sort table js function tdubyou JavaScript 0 05-03-04 10:19 AM
Using Perl to sort times in mysql perleo PHP 1 01-04-04 05:57 PM
Need script sort of like Hotscripts.com Abu Mami General HotScripts Site Discussion 5 08-04-03 07:04 PM
Better Hotscripts Rating Algorithm (sort order) jv2222 Hot Scripts Forum Questions, Suggestions and Feedback 13 06-21-03 06:54 AM


All times are GMT -5. The time now is 01:31 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.