Public Class Form2
    Dim kc As New Collection   '模块级定义，为
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDel.Click
        Dim strDel As String
        strDel = InputBox("请输入要删除的课程号：")
        If kc.Contains(strDel) Then
            kc.Remove(strDel)
            MsgBox("删除成功！")
        Else
            MsgBox("不存在该课程号！")
        End If
        Dim x As Object
        Dim strtemp As String = ""
        For Each x In kc
            strtemp = strtemp & x & vbTab
        Next
        TextBox3.Text = strtemp

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        kc.Add(TextBox2.Text, TextBox1.Text)
        Dim x As Object
        Dim strtemp As String = ""
        For Each x In kc
            strtemp = strtemp & x & vbTab
        Next
        TextBox3.Text = strtemp
        TextBox1.Text = ""
        TextBox2.Text = ""
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSrch.Click
        Dim strSrch As String
        strSrch = InputBox("请输入要查找的课程号：")
        If kc.Contains(strSrch) Then
            TextBox1.Text = strSrch
            TextBox1.Text = kc.Item(strSrch)
        Else
            MsgBox("不存在该课程！") '
        End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalcu.Click
        Label3.Text = "共有:" & kc.Count & " 门课程"
    End Sub

   
End Class