| | |
case statement not working
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2009
Posts: 66
Reputation:
Solved Threads: 0
I have a case statement that evaluates a string in a combo box on a form which is either English or Metric. What I'm finding is that the case statement does not see the pull down box contents which is loaded by default unless it is physically reselected by the user. In other words the combo box defaults to "metric" but the case statement does not recognize it unless I go and reselect "metric" in the combo box. Any help would be appreciated.
•
•
Join Date: Feb 2009
Posts: 66
Reputation:
Solved Threads: 0
•
•
•
•
Show some code, show the line with the error, show what you tried to do to fix it
switch (bunitsCB.Text)
{
case "Metric":
bl = Convert.ToDecimal(blanklTB.Text) / Convert.ToDecimal(25.4);
bw = Convert.ToDecimal(blankwTB.Text) / Convert.ToDecimal(25.4);
bp = Convert.ToDecimal(blankpTB.Text) / Convert.ToDecimal(25.4);
pd = Convert.ToDecimal(partdepthTB.Text) / Convert.ToDecimal(25.4);break;
case "English":
bl = Convert.ToDecimal(blanklTB.Text);
bw = Convert.ToDecimal(blankwTB.Text);
bp = Convert.ToDecimal(blankpTB.Text);
pd = Convert.ToDecimal(partdepthTB.Text);break;
default:
bl = 0;
bw = 0;
bp = 0;
pd = 0;
checkLB.Items.Add("YOU MUST SELECT A BLANK UNIT OF MEASURE");break;
}
switch (dieunitsCB.Text)
{
case "Metric":
dl = Convert.ToDecimal(dielTB.Text) / Convert.ToDecimal(25.4);
dw = Convert.ToDecimal(diewTB.Text) / Convert.ToDecimal(25.4);
ds = Convert.ToDecimal(dieshTB.Text) / Convert.ToDecimal(25.4);break;
case "English":
dl = Convert.ToDecimal(dielTB.Text);
dw = Convert.ToDecimal(diewTB.Text);
ds = Convert.ToDecimal(dieshTB.Text);break;
default:
dl = 0;
dw = 0;
ds = 0;
checkLB.Items.Add("YOU MUST SELECT A DIE UNIT OF MEASURE");break;
}
![]() |
Similar Threads
- if statement not working (C++)
- Functions not working (Python)
- Converting MYSQL statement to MSSQL (MS SQL)
- Switch Statement output error (PHP)
- Help with switch/case statement navigation (PHP)
- Problem w/ LIMIT in CASE statement (MySQL)
- Else Statement always Returns True (C++)
- need help with an IF statement (C++)
Other Threads in the C# Forum
- Previous Thread: operator overloading
- Next Thread: Passing Parameters/Arguments to a C# .NET Program
| Thread Tools | Search this Thread |
.net 2007 access ado.net algorithm array barchart bitmap box broadcast buttons c# camera check checkbox client color combobox control conversion cs4 csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event eventcloseformc# excel file files form format forms function gdi+ httpwebrequest image index input install ip java label list listbox listener listview load mandelbrot math mouseclick mysql operator path photoshop picturebox pixelinversion post programming radians regex remote remoting richtextbox security serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer update usercontrol validation visual visualstudio webbrowser windows winforms wordautomation wpf xml






