|
-
Apr 28th, 2005, 11:16 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Switch Statement Generate Error
Switch Statement Generate Error
:not all code paths return a value
public string DentMode(string RecMode,int ButtNo)
{
switch(ButtNo)
{
case 1:
Toolbarx.Buttons[1].Enabled = false;
return "A";
case 2:
Toolbarx.Buttons[2].Enabled = false;
codeFld.Enabled = false;
codeFld.Focus();
return "E";
case 3:
Toolbarx.Buttons[3].Enabled = false;
codeFld.Enabled = false;
return "D";
case 5:
Toolbarx.Buttons[1].Enabled = true;
Toolbarx.Buttons[2].Enabled = true;
Toolbarx.Buttons[3].Enabled = true;
return "";
}
Last edited by Waseemalisyed; May 10th, 2005 at 06:33 AM.
Reason: ok
-
Apr 29th, 2005, 03:44 AM
#2
Re: Switch Statement Generate Error
if 1,2,3,5 is not the value OF bUTTnO then the return statement won't get executed.
Code:
public string DentMode(string RecMode,int ButtNo)
{
string ret="";
switch(ButtNo)
{
case 1:
Toolbarx.Buttons[1].Enabled = false;
ret "A";
break;
case 2:
Toolbarx.Buttons[2].Enabled = false;
codeFld.Enabled = false;
codeFld.Focus();
ret "E";
break;
case 3:
Toolbarx.Buttons[3].Enabled = false;
codeFld.Enabled = false;
ret "D";
break;
case 5:
Toolbarx.Buttons[1].Enabled = true;
Toolbarx.Buttons[2].Enabled = true;
Toolbarx.Buttons[3].Enabled = true;
ret "";
break;
}
return ret;
}
you might also want a defult case
-
Apr 29th, 2005, 04:04 AM
#3
Thread Starter
Addicted Member
Re: Switch Statement Generate Error
Thanks for this coperation
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|