I have a class work whose need is to use a sort algorithm to sort a list of random numbers.
My problem is that I'm throwing the items from the list of random numbers into an array, implementing the computer method and putting the ordered numbers into a second list.
But when I'm doing this, it always returns the number 0, or the int32 [] array error. How should I proceed?
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim min As Integer
Dim max As Integer
Dim i As Integer
Dim j As Integer
Dim best_value As Long
Dim best_j As Integer
For i = min To max - 1
best_value = ve(i)
best_j = i
For j = i + 1 To max
If ve(j) < best_value Then
best_value = ve(j)
best_j = j
End If
Next j
vl(best_j) = vl(i)
vl(i) = best_value
Next i
Dim h As Integer
For h = 0 To 1
Lst.Items.Add(vl(h))
Next h
End Sub
In this code VE
is the array of random numbers, VL
is the array of numbers already sorted and lst
is the listbox for which numbers are sorted.