View Single Post
  #1  
Old 15-12-2009, 11:07 PM
.BZU.'s Avatar
.BZU. .BZU. is offline


 
Join Date: Sep 2007
Location: near Govt College of Science Multan Pakistan
Posts: 9,693
Contact Number: Removed
Program / Discipline: BSIT
Class Roll Number: 07-15
.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute
Default Program for Sorting the elements of an Array (bubble Sort) VB Code (By Sheraz)

Code:
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
   
   
  

__________________
(¯`v´¯)
`*.¸.*`

¸.*´¸.*´¨) ¸.*´¨)
(¸.*´ (¸.
Bzu Forum

Don't cry because it's over, smile because it happened
Reply With Quote