3
Reply

All paths do not return value help

Ask a question
Daniel

Daniel

17y
1.6k
1
Please help. I am getting the error "all paths do not return a value" I can't find it. THANKS IN ADVANCE FOR ANY SUGGESTIONS: HERE'S THE CODE:

private CheckBox FindCheckBox(string sCtrlName)
{
foreach (CheckBox chkTemp in this.Controls)
{
//CheckBox chkTemp = new CheckBox();

//if str is greater than -1, then string was found
if (sCtrlName.IndexOf("YES") > -1)
{
//since YES is selected, find and return
//the "NO" control
int endPos = sCtrlName.IndexOf("_");
string sName = sCtrlName.Substring(0, endPos);

sName += "_NO";

if (chkTemp.Name == sName)
{
//chkTemp = (CheckBox)c;
return chkTemp;
}
}
else
{
//since NO is selected, find and return
//the "YES" control
int endPos = sCtrlName.IndexOf("_");
string sName = sCtrlName.Substring(0, endPos);

sName += "_YES";

if (chkTemp.Name == sName)
{
//chkTemp = (CheckBox)c;
return chkTemp;
}
return chkTemp;
}
}
}

Answers (3)