'Project: Select Case and Dialog Result 'Programmer: 'Date: Winter 2008 Public Class mainForm 'Const m_TAX_RATE_decimal As Decimal = 0.09D Const m_carPriceInteger As Integer = 8500I Private Sub calculateButton_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles calculateButton.Click Dim totalDecimal As Decimal Dim taxDecimal As Decimal Dim taxRateDecimal As Decimal Dim finalTotalDecimal As Decimal Dim userResponseDialogResult As DialogResult 'Establish base price of car totalDecimal = m_carPriceInteger 'Determine if checkboxes for accessories have 'been chosen, if so then add the accessory price 'to base price of car If fmCheckBox.Checked = True Then totalDecimal += 50D End If If cdCheckBox.Checked = True Then totalDecimal += 100D End If 'Determining the tax rate by 'examing the state textbox Select Case stateTextbox.Text.ToUpper Case "CA", "NV" taxRateDecimal = 0.09D Case "OR" taxRateDecimal = 0D Case "WA" taxRateDecimal = 0.08D Case "ID" taxRateDecimal = 0.07D End Select 'Applying tax rate to total to get tax taxDecimal = totalDecimal * taxRateDecimal 'Add tax to subtotal for final total finalTotalDecimal = totalDecimal + taxDecimal 'Determine which color radio button was chosen If blueRadioButton.Checked = True Then priceLabel.BackColor = Color.Blue Else If yellowRadioButton.Checked = True Then priceLabel.BackColor = Color.Yellow Else If greenRadioButton.Checked = True Then priceLabel.BackColor = Color.Green End If End If End If 'If the final total is more than $9,000 then 'ask user if they want to buy the car by capturing 'the users response to the messagebox Select Case finalTotalDecimal Case Is > 9000 userResponseDialogResult = MessageBox.Show("Are you sure you want to buy this?", "Warning", MessageBoxButtons.YesNo,MessageBoxIcon.Warning) End Select 'examine the messagebox result If userResponseDialogResult = Windows.Forms.DialogResult.Yes Then priceLabel.Text = FormatCurrency(finalTotalDecimal) Else priceLabel.Text = "" End If End Sub Private Sub exitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitButton.Click Dim userResponseDialogResult As DialogResult 'Ask user if they want to shut down the program userResponseDialogResult = MessageBox.Show("Are you sure you want to Exit?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) 'If the user want to shut down the program, then do it. If userResponseDialogResult = Windows.Forms.DialogResult.Yes Then Me.Close() End If End Sub End Class