' Project: Select Case and Nesting ' Programmer: Andy McCone ' Date: April 8th 2008 'Description: This program shows off some nesting ' strategies and a little bit of Select Case Option Strict On Public Class mainForm 'Declare Constant Const m_CAR_PRICE_integer 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 'Check to see if the State textbox is filled out If stateTextbox.Text <> "" Then 'Populate the local variable totalDecimal 'with the base price of the car totalDecimal = m_CAR_PRICE_integer 'Check to see which color was choosen 'and change the priceLabel background to that color If blueRadioButton.Checked = True Then priceLabel.BackColor = Color.Blue Else If yellowRadioButton.Checked = True Then priceLabel.BackColor = Color.Yellow Else priceLabel.BackColor = Color.Green End If End If 'Check the checkboxes and add to the 'base price of the car If fmCheckBox.Checked = True Then totalDecimal += 50D End If If cdCheckBox.Checked = True Then totalDecimal += 100D End If If gpsCheckBox.Checked = True Then totalDecimal += 300D End If 'Determine the tax based on the state Select Case stateTextbox.Text.ToUpper Case "SD", "ND" taxDecimal = 0.09D * totalDecimal Case "WA" taxDecimal = 0.16D * totalDecimal Case "ME" taxDecimal = 0.038D * totalDecimal Case Else taxDecimal = 0D End Select 'Add the tax to the running total of the car price totalDecimal += taxDecimal 'Display the total car price with tax priceLabel.Text = totalDecimal.ToString("c") Else MessageBox.Show("Please fill out the State", "Hello?", MessageBoxButtons.OK, MessageBoxIcon.Hand) End If End Sub End Class