Public Class Form1
    Dim PoleNahodnychCisel(0 To 499) As Long

    'Inicializace objektu typu ProgressBar a zobrazeni poctu prvku
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        UkazatelPostupu.Minimum = 0
        UkazatelPostupu.Maximum = PoleNahodnychCisel.GetUpperBound(0)
        UkazPostMax.Text = PoleNahodnychCisel.GetUpperBound(0) + 1
    End Sub

    'Naplneni pole nahodnymi cisly a jeho zobrazeni v textovem poli
    Private Sub TlacitkoNaplneniPole_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TlacitkoNaplneniPole.Click
        Dim i As Integer
        For i = 0 To PoleNahodnychCisel.GetUpperBound(0)
            PoleNahodnychCisel(i) = Int(Rnd() * 1000000)
            TextovePoleObsah.Text = TextovePoleObsah.Text & PoleNahodnychCisel(i) & vbCrLf
            'posun ukazatele postupu
            UkazatelPostupu.Value = i
        Next i
    End Sub

    'Vzestupne razeni pole metodou Array.Sort a zobrazeni serazeneho vysledku
    Private Sub TlacitkoVzestRPole_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TlacitkoVzestRPole.Click
        Dim i As Integer
        TextovePoleObsah.Text = ""
        Array.Sort(PoleNahodnychCisel)
        For i = 0 To PoleNahodnychCisel.GetUpperBound(0)
            TextovePoleObsah.Text = TextovePoleObsah.Text & PoleNahodnychCisel(i) & vbCrLf
            'posun ukazatele postupu
            UkazatelPostupu.Value = i
        Next i
    End Sub

    'Sestupne razeni pole metodou Array.Reverse a zobrazeni serazeneho vysledku
    Private Sub TlacitkoSestRPole_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TlacitkoSestRPole.Click
        Dim i As Integer
        TextovePoleObsah.Text = ""
        Array.Reverse(PoleNahodnychCisel)
        For i = 0 To PoleNahodnychCisel.GetUpperBound(0)
            TextovePoleObsah.Text = TextovePoleObsah.Text & PoleNahodnychCisel(i) & vbCrLf
            'posun ukazatele postupu
            UkazatelPostupu.Value = i
        Next i
    End Sub
End Class
