VB Code:
Private Sub addButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addButton.Click
' Adds a new movie categroy to the category list.
With movieCategoryComboBox
' Test for blank input.
If .Text <> "" Then
' Make sure the item is not already selected.
Dim itemFoundBoolean As Boolean
Dim itemIndexInteger As Integer
Do Until itemFoundBoolean Or itemIndexInteger = movieCategoryComboBox.Items.Count
If .Text = [U].Items(itemIndexInteger).ToSting()[/U] Then
itemFoundBoolean = True
End If
itemIndexInteger += 1
Loop
If itemFoundBoolean Then
MessageBox.Show("Duplicate Item", "Add Failed")
Else
' If it's not in the list then add it.
.Items.Add(.Text)
.Text = ""
End If
Else
MessageBox.Show("Enter a Movie Category To Add", "Missing Data", _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
.Focus()
End With
End Sub