case statement not working

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2009
Posts: 66
Reputation: MJV is an unknown quantity at this point 
Solved Threads: 0
MJV MJV is offline Offline
Junior Poster in Training

case statement not working

 
0
  #1
Feb 23rd, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: case statement not working

 
0
  #2
Feb 23rd, 2009
Whats wrong with the other question you already have a thread on this subject for?
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 66
Reputation: MJV is an unknown quantity at this point 
Solved Threads: 0
MJV MJV is offline Offline
Junior Poster in Training

Re: case statement not working

 
0
  #3
Feb 23rd, 2009
different problem
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 99
Reputation: Clawsy is an unknown quantity at this point 
Solved Threads: 5
Clawsy Clawsy is offline Offline
Junior Poster in Training

Re: case statement not working

 
0
  #4
Feb 23rd, 2009
i don't understand very well your problem. Give us the code, example... don't let us guess.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 45
Reputation: bcasp is an unknown quantity at this point 
Solved Threads: 10
bcasp bcasp is offline Offline
Light Poster

Re: case statement not working

 
0
  #5
Feb 23rd, 2009
If this is the problem I think it is, I usually fix it by using the Text property of the combo box. It should allow you to get the text of what's in the combo box without the user actually having to select it.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 66
Reputation: MJV is an unknown quantity at this point 
Solved Threads: 0
MJV MJV is offline Offline
Junior Poster in Training

Re: case statement not working

 
0
  #6
Feb 23rd, 2009
that is what im using the text property of the combo box
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 45
Reputation: bcasp is an unknown quantity at this point 
Solved Threads: 10
bcasp bcasp is offline Offline
Light Poster

Re: case statement not working

 
0
  #7
Feb 23rd, 2009
OK...have you tried using the SelectedItem property?
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 66
Reputation: MJV is an unknown quantity at this point 
Solved Threads: 0
MJV MJV is offline Offline
Junior Poster in Training

Re: case statement not working

 
0
  #8
Feb 26th, 2009
Originally Posted by bcasp View Post
OK...have you tried using the SelectedItem property?
Yes I get an error saying " a value of an integral type is expected"
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: case statement not working

 
0
  #9
Feb 26th, 2009
Show some code, show the line with the error, show what you tried to do to fix it
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 66
Reputation: MJV is an unknown quantity at this point 
Solved Threads: 0
MJV MJV is offline Offline
Junior Poster in Training

Re: case statement not working

 
0
  #10
Feb 26th, 2009
Originally Posted by LizR View Post
Show some code, show the line with the error, show what you tried to do to fix it
Here is my code and when I run it always gets to the default althought there are strings showing in the combo box that came from the data base

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;
}
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC