| | |
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
Views: 801 | Replies: 13
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array barchart bitmap box broadcast button buttons c# chat check checkbox class client code color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files form format forms ftp function gdi+ http httpwebrequest image index input install java label list listbox login mandelbrot math mysql networking operator oracle path photoshop picturebox pixelinversion prime programming radians regex remote remoting resource richtextbox save saving serialization server socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view webbrowser windows winforms wpf xml






