TEAM CODING-BCA

VB program to implement Bubble sort.

BUBBLE SORT


Private Sub Command1_Click()
Dim s As Integer
Dim n As Integer
Dim a() As Integer
Dim i As Integer
Dim j As Integer
Dim swap As Integer
s = InputBox("array size")
ReDim a(s)
For i = 0 To s - 1
a(i) = InputBox("enter")
List1.AddItem a(i)
Next
For i = 0 To s - 1
For j = i + 1 To s - 1
If a(i) > a(j) Then
n = i
swap = a(n)
a(n) = a(j)
a(j) = swap
End If
Next
Next
For i = 0 To s - 1
List2.AddItem a(i)
Next

End Sub

No comments:

Post a Comment