//***********START OF MY CODE************ static double salesTaxRate = 0; //class level variable private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { //---fill the combo box cboStates->Items->Add("CA"); cboStates->Items->Add("AZ"); cboStates->Items->Add("NV"); cboStates->Items->Add("OR"); cboStates->Items->Add("WA"); cboStates->SelectedIndex =0; // make sure the first one is selected } private: System::Void btnOK_Click(System::Object^ sender, System::EventArgs^ e) { //---now decide the sales tax rate based upon the state they chose MessageBox::Show("The sales tax for " + cboStates->SelectedItem->ToString() + " is " + salesTaxRate + ".", "Using Switch" , MessageBoxButtons::OK, MessageBoxIcon::Information); } private: System::Void cboStates_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) { /* ---now decide the sales tax rate based upon the state they chose. C++ will not let you evaluate a string using switch like you can in VB & C#. That is why it is easier to use a combo box and switch on the index number. */ switch (cboStates->SelectedIndex) { case 0: //CA salesTaxRate = .08; break; case 1: //AZ salesTaxRate = .05; break; case 2: //NV salesTaxRate = .01; break; case 3: //OR and WA are the same. If they choose OR, the switch "falls through" to case 4. Both OR and WA will have the same sales tax case 4: //WA salesTaxRate = .06; break; } }