
15-12-2009, 11:07 PM
|
 | | |
Join Date: Sep 2007 Location: near Govt College of Science Multan Pakistan
Posts: 9,675
Contact Number: Removed Program / Discipline: BSIT Class Roll Number: 07-15 | |
Program for Sorting the elements of an Array (bubble Sort) VB Code (By Sheraz) |  | | | Module Module1 Sub Main() Dim ar As Integer() Dim temp As Integer Dim my_index As Integer ar = New Integer() {15, 8, 1, 6, 34, 7, 5, 342, 4, 9} my_index = ar.GetUpperBound(0) For j = 0 To 8 For i = 0 To my_index - 1 ' 1 is subtrcted to avoid INDEX OUT OF RANGE If ar(i) > ar(i + 1) Then temp = ar(i) ar(i) = ar(i + 1) ar(i + 1) = temp End If Next my_index = my_index - 1 Next For k = 0 To ar.GetUpperBound(0) Console.WriteLine(ar(k)) Next Console.ReadLine() End Sub End Module | | |  | | | |