Public Class pizza3 Private Sub SubmitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SubmitButton.Click Submit() End Sub Private Sub ResetButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ResetButton.Click Reset() End Sub Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click Me.Dispose() End Sub Private Sub Reset() 'Reset all the fields and buttons NameTextBox.Text = "" AddressTextBox.Text = "" SizeComboBox.Text = "Large" ToppingsListBox.SelectedIndex = -1 DebugTextBox.Text = "The status of your order is:" End Sub Private Sub Submit() 'Declare variables Dim outputStream As System.IO.StreamWriter Dim i As Integer 'Check for missing name If NameTextBox.Text = "" Then FormError("Missing name field") Exit Sub End If 'Check for missing address If AddressTextBox.Text = "" Then FormError("Missing name field") Exit Sub End If 'Confirm submission action i = MsgBox("Are your sure you want to order this pizza?", _ vbQuestion + vbOKCancel, "Order confirmation") If i = vbCancel Then Exit Sub End If 'Write output to a text file 'Open output file outputStream = My.Computer.FileSystem.OpenTextFileWriter("c:\cs350\pizza3\orders.txt", True) outputStream.WriteLine("---------------------------------------------") outputStream.WriteLine("Name: " & NameTextBox.Text) outputStream.WriteLine("Address: " & AddressTextBox.Text) outputStream.WriteLine("Size: " & SizeComboBox.Text) outputStream.WriteLine("Toppings: " & SelectedToppings()) outputStream.Close() MsgBox("Thank you for ordering from Purple Pizza Parlor." & vbCrLf _ & "Your order will be delivered in about a half hour.") End Sub Private Sub FormError(ByVal message As String) MsgBox(message, vbExclamation, "Form Error") End Sub Private Sub SizeComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SizeComboBox.SelectedIndexChanged DebugTextBox.Text = DebugTextBox.Text & vbCrLf & SizeComboBox.Text & " chosen" End Sub Private Function SelectedToppings() As String Dim toppings As String = "" Dim i As Integer Dim count As Integer = ToppingsListBox.SelectedItems.Count Dim started As Boolean = False For i = 0 To count - 1 If started Then toppings = toppings & ", " Else started = True End If toppings = toppings & ToppingsListBox.SelectedItems(i) Next Return toppings End Function Private Sub ToppingsListBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToppingsListBox.SelectedIndexChanged Dim toppings As String toppings = "Toppings chosen: " & SelectedToppings() DebugTextBox.Text = DebugTextBox.Text & vbCrLf & toppings End Sub Private Sub SubmitMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SubmitMenuItem.Click Submit() End Sub Private Sub ResetMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ResetMenuItem.Click Reset() End Sub Private Sub ExitMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitMenuItem.Click Me.Dispose() End Sub Private Sub AboutMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutMenuItem.Click Dim frm As New AboutBox() frm.ShowDialog(Me) frm.Dispose() End Sub Private Sub AnotherFormMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AnotherFormMenuItem.Click Dim frm As New AnotherForm() frm.ShowDialog(Me) frm.Dispose() End Sub End Class