Public Class Uzke_misto
    Public MaticePreserizeni(,) As Single
    Public PocetZakazek As Short
    Public Matice_stejne_zakazky As Boolean

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load


    End Sub

    Private Sub PocDruhZak_Button_Click(sender As Object, e As EventArgs) Handles PocDruhZak_Button.Click
        Dim j As Integer
        If RadioButton1.Checked = True Then
            Matice_stejne_zakazky = True
        Else
            Matice_stejne_zakazky = False
        End If


        If IsNumeric(PocDruhZak.Text) Then
            PocetZakazek = Convert.ToInt16(PocDruhZak.Text)
            MaticeReady_Button.Enabled = True
            Dim i As Integer
            For i = 1 To PocetZakazek
                Matice1.Columns.Add("Sloupec" & i, "Na " & i & ". výrobek [min]")
                Matice1.Rows.Add()
                Matice1.Rows(i - 1).HeaderCell.Value = "Přeseřízení z " & i & ". výrobku [min]"
            Next
        Else
            MsgBox("Počet druhů zakázek musí být číslo!")
        End If

        If RandomValues.Checked = True Then
            For i = 0 To PocetZakazek - 1
                For j = 0 To PocetZakazek - 1
                    Matice1.Rows(i).Cells(j).Value = CInt(Math.Ceiling(Rnd() * 60)) + 1

                Next
            Next
        End If

        If Matice_stejne_zakazky = False Then
            For i = 0 To PocetZakazek - 1
                Matice1.Rows(i).Cells(i).Value = "----------"
            Next
        End If
        ReDim MaticePreserizeni(PocetZakazek - 1, PocetZakazek - 1)




    End Sub

    Private Sub MaticeReady_Button_Click(sender As Object, e As EventArgs) Handles MaticeReady_Button.Click
        Dim i, j As Integer
        Dim var As String
        'Dim var1 As String

        'var1 = Matice1.Rows(2).Cells(2).Value
        'MsgBox(var1)

        For i = 0 To PocetZakazek - 1
            For j = 0 To PocetZakazek - 1


                var = Matice1.Rows(i).Cells(j).Value

                If (Matice_stejne_zakazky = False) And (i = j) Then

                    MaticePreserizeni(i, j) = 0


                Else
                    If IsNumeric(var) Then
                        'MsgBox(var)
                        MaticePreserizeni(i, j) = Convert.ToInt32(var)
                    Else
                        MsgBox("Matice musí obsahovat pouze čísla!")
                        Exit Sub
                    End If
                End If

            Next

        Next

        Form2.Show()

    End Sub

    Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton2.CheckedChanged


    End Sub

    Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton1.CheckedChanged


    End Sub
End Class

