I have a question and here is what I am trying to do.

Generate an array of 20 random numbers between 1-100
Display them as generated
Sort them into descending order (Starting with the largest and going to the smallest
Display the results

I have started writing the code but I am not sure where to go from here.

If anybody can send me in the right direction it would be greatly appreciated.

Thanks

Public Class Form1

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        Dim x As Double
        Dim i As Integer
        Dim sortarray(20)
        Randomize()
        For i = 1 To 20
            sortarray(i) = Rnd() * 100
        Next
        For i = 1 To 20
            ListBox1.Text.add(sortarray(i))
        Next
    End Sub
End Class
Attachments hw.jpg 39.67 KB
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim x As Double
        Dim i As Integer
        Dim sortarray(20) As Integer
        Randomize()
        For i = 1 To 20
            sortarray(i) = Rnd() * 100
        Next
        Array.Sort(sortarray)
        For i = sortarray.GetUpperBound(0) To 0 Step -1
            ListBox1.Items.Add(sortarray(i).ToString)
        Next i
    End Sub
This question has already been answered. Start a new discussion instead.