Public Class Form1
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ComboBox1.Items.Add("中国")
        ComboBox1.Items.Add("美国")
        ComboBox1.Items.Add("日本")
        ComboBox1.Items.Add("韩国")
        ComboBox1.Items.Add("马来西亚")
        ComboBox1.Text = ""
    End Sub
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        TextBox1.Text = ComboBox1.Text
    End Sub
    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Flag As Boolean = False
        ' 标志变量Flag表示需要添加 
        If ComboBox1.Text <> "" Then
            For i As Integer = 0 To ComboBox1.Items.Count - 1
                If ComboBox1.Items(i).ToString() = ComboBox1.Text Then
                    Flag = True
                    '该国家名称已经存在，无须添加 
                    Exit For
                End If
            Next
            If Flag = False Then
                ComboBox1.Items.Add(ComboBox1.Text)
            End If
        Else
            MessageBox.Show("请先输入国家名称","提示")
        End If
    End Sub
    Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        If ComboBox1.SelectedIndex = -1 Then
            MessageBox.Show("请选择要删除的项目!", "提示")
        Else
            ComboBox1.Items.RemoveAt(ComboBox1.SelectedIndex)
        End If
    End Sub
    Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
        Application.Exit()
    End Sub
End Class
