Im getting an "unknown selection" error on this code. Can anyone help me. I don't know what is wrong. My two text boxes both have English selected. blankl and blanlkw have both been initialized as decimals.

if (bunitsCB.Text == "English")
                {                
                    switch (dieunitsCB.Text)
                    {
                        case "English":
                            dielTB.Text = Convert.ToString(blankl + Convert.ToDecimal(24));
                            diewTB.Text = Convert.ToString(blankw + Convert.ToDecimal(24)); break;
                        case "Metric":
                            dielTB.Text = Convert.ToString(Math.Round((blankl * Convert.ToDecimal(25.4)), 0) + Convert.ToDecimal(588));
                            diewTB.Text = Convert.ToString(Math.Round((blankw * Convert.ToDecimal(25.4)), 0) + Convert.ToDecimal(588)); break;
                        default:
                            throw new Exception("Unknown selection");
                    }
                 }
                else
                {
                    switch (dieunitsCB.Text)
                    {
                        case "English":
                            dielTB.Text = Convert.ToString(Math.Round((blankl / Convert.ToDecimal(25.4)), 0) + Convert.ToDecimal(24));
                            diewTB.Text = Convert.ToString(Math.Round((blankw / Convert.ToDecimal(25.4)), 0) + Convert.ToDecimal(24)); break;                           
                        case "Metric":                            
                            dielTB.Text = Convert.ToString(blankl + Convert.ToDecimal(588));
                            diewTB.Text = Convert.ToString(blankw + Convert.ToDecimal(588)); break;
                        default:
                            throw new Exception("Unknown selection");
                    }
                }

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Side comment - with 18 post under your belt, you should have known enough to wrap your code in code tags.

[code] ... your code here ... [/code] at least, but for this forum, preferably [code=c#] ... [/code]

This article has been dead for over six months. Start a new discussion instead.