muhammad ibrahim
asked on
i want help with this insertion sort in vb.net windows form..
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim array(6) As Integer
array(0) = 7
array(1) = 2
array(2) = 4
array(3) = 1
array(4) = 5
array(5) = 3
Dim value As Integer
Dim i As Integer
Dim n As Integer
For j = 1 To n - 1
value = array(j)
i = j - 1
While (i > 0 And array(i) > value)
array(i + 1) = array(i)
i = i - 1
array(i + 1) = value
End While
Next j
Dim stOut As String
For i = 0 To 6
stOut = ListBox1.Items.Add(array(i )) & vbNewLine
Next
End Sub
End Class
got this code and its showing the same output values as i initialized.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim array(6) As Integer
array(0) = 7
array(1) = 2
array(2) = 4
array(3) = 1
array(4) = 5
array(5) = 3
Dim value As Integer
Dim i As Integer
Dim n As Integer
For j = 1 To n - 1
value = array(j)
i = j - 1
While (i > 0 And array(i) > value)
array(i + 1) = array(i)
i = i - 1
array(i + 1) = value
End While
Next j
Dim stOut As String
For i = 0 To 6
stOut = ListBox1.Items.Add(array(i
Next
End Sub
End Class
got this code and its showing the same output values as i initialized.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Provided solution.