Private Sub PrintToolStripMenuItem_Click(ByVal sender As System.Object, ByVa
l e As System.EventArgs) Handles PrintToolStripMenuItem.Click PrintPreviewDialog1 End Sub Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click 'Declare dialog result variable Dim ResponseDialogResult As DialogResult = MessageBox.Show("Confirm Exit ?", "Exit ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaul tButton.Button2) If ResponseDialogResult = Windows.Forms.DialogResult.Yes Then 'Exit the program Me.Close() End If End Sub Private Sub AddNewCatalogToolStripMenuItem_Click(ByVal sender As System.Obje ct, ByVal e As System.EventArgs) Handles AddNewCatalogToolStripMenuItem.Click 'Add part text property to ComboBox listing 'if not the empty string If CatalogNameComboBox.Text.Trim <> String.Empty Then 'Ok to add CatalogNameComboBox.Items.Add(CatalogNameComboBox.Text) Else 'Cannot add MessageBox.Show("You must type a new catalog name.", "Catalog Name M issing Error", MessageBoxButtons.OK, MessageBoxIcon.Error) CatalogNameComboBox.Focus() End If End Sub Private Sub RemoveExistingCatalogToolStripMenuItem_Click(ByVal sender As Sys tem.Object, ByVal e As System.EventArgs) Handles RemoveExistingCatalogToolStripM enuItem.Click 'Try to remove the catalog if one is selected Try 'Declare dialog result variable Dim ResponseDialogResult As DialogResult = MessageBox.Show("Remove t he selected catalog?", "Remove ?", MessageBoxButtons.YesNo, MessageBoxIcon.Quest ion, MessageBoxDefaultButton.Button2) If ResponseDialogResult = Windows.Forms.DialogResult.Yes Then 'Remove the selected catalog from the listing CatalogNameComboBox.Items.RemoveAt(CatalogNameComboBox.SelectedI ndex) 'This next line of code clears the Text 'property of the ComboBox this is automatic 'for the Remove method, but not for the last 'item in a list. CatalogNameComboBox.Text = String.Empty End If Catch ex As ArgumentOutOfRangeException MessageBox.Show("You must select a catalog to remove.", "No Selectio n Was Made", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub Private Sub CountTheNumberOfCatalogDisplayedToolStripMenuItem_Click(ByVal se nder As System.Object, ByVal e As System.EventArgs) Handles CountTheNumberOfCata logDisplayedToolStripMenuItem.Click 'Display a message box with the count of the number of part Dim MessageString As String = "Number of Parts: " & CatalogListBox.Items .Count.ToString() Dim TitleString As String = "Count of Parts" MessageBox.Show(MessageString, TitleString, MessageBoxButtons.OK, Messag eBoxIcon.Information) End Sub Private Sub ClearCatalogListToolStripMenuItem_Click(ByVal sender As System.O bject, ByVal e As System.EventArgs) Handles ClearCatalogListToolStripMenuItem.Cl ick 'Use response variable to capture user response Dim ResponseDialogResult As DialogResult = MessageBox.Show("Clear all li sting Y/N?", "Yes or No", MessageBoxButtons.YesNo, MessageBoxIcon.Question, Mess ageBoxDefaultButton.Button2) 'Test to confirm whether to clear listing If ResponseDialogResult = Windows.Forms.DialogResult.Yes Then CatalogNameComboBox.SelectedIndex = -1 QuantityTextBox.Clear() CatalogListBox.SelectedIndex = -1 CatalogNameComboBox.Focus() End If End Sub Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVa l e As System.EventArgs) Handles AboutToolStripMenuItem.Click 'Display about message box Dim MessageString As String = "Programmed by Muhamad Aifaa Md Fadzil" & ControlChars.NewLine & "Today's Date/Time: " & Date.Now.ToString Dim TitleString As String = "About the Catalog" 'Display output message MessageBox.Show(MessageString, TitleString, MessageBoxButtons.OK, Messag eBoxIcon.Information) End Sub Private Sub AddButton_Click(ByVal sender As System.Object, ByVal e As System .EventArgs) Handles AddButton.Click End Sub Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As Syste m.EventArgs) Handles ExitButton.Click 'Declare dialog result variable Dim ResponseDialogResult As DialogResult = MessageBox.Show("Confirm Exit ?", "Exit ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaul tButton.Button2) If ResponseDialogResult = Windows.Forms.DialogResult.Yes Then 'Exit the program Me.Close() End If End Sub End Class