Public Class ClassList
    ' Exam Number: 6786786786
    Public Counter As Integer
    Public Counter2 As Integer = 0
    Public Amountarray() As String
    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        ' Exit the Program
        Me.Close()
    End Sub
    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        ' Clear the Textbox and Listbox using an procedure 
        ClearTextbox()
    End Sub
    Private Sub btnAmount_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAmount.Click
        ' Setup the Amount of students in the class
        Counter = CInt(txtAmount.Text) - 1     ' Has to subtract 1 - Array starts counting at 0
        ReDim Amountarray(Counter)
        If txtAmount.Text > 0 Then
            GroupBox1.Enabled = True
        End If
        txtAmount.Clear()
    End Sub
    Private Sub btnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnter.Click
        ' Enter Students into the Array.
        Dim a As Integer
        Amountarray(Counter2) = txtName.Text & " " & txtSurname.Text
        lstClassList.Sorted = True
        txtName.Focus()
        txtName.Clear()
        txtSurname.Clear()
        If Counter2 = Counter Then
            MsgBox(" Limit was reached")
            For a = 0 To Counter
                lstClassList.Items.Add(Amountarray(a))
            Next
            Exit Sub
        End If
        Counter2 = Counter2 + 1
    End Sub
    Sub ClearTextbox()
        'Procedure to clear textboxes
        txtName.Clear()
        txtAmount.Clear()
        txtSurname.Clear()
    End Sub
End Class
