Hi,
I have a public function named GetQuarter() that I created under class named Default. I also created another public Class namded Class1. I tried to use the GetQuarter class in Class1. So I created an instance for the class Default and call the GetQuarter function. The GetQuarter function accesses the Default class' radiobuttion member controls and assign a value to a variable depending on the radiobutton selected. I always get an error :
Object reference not set to an instance of an object.
Here is my code from class Default
public partial class _Default : System.Web.UI.Page
{
public short GetQuarter(short ch)
{
short Q=0;
switch (ch)
{
case 1:
if (radFrmDashQ1.Checked)
Q = 1;
else if (radFrmDashQ2.Checked)
Q = 2;
else if (radFrmDashQ3.Checked)
Q = 3;
else
Q = 4;
break;
case 2:
if (radToDashQ1.Checked)
Q = 1;
else if (radToDashQ2.Checked)
Q = 2;
else if (radToDashQ3.Checked)
Q = 3;
else
Q = 4;
break;
default:
Q = 0;
break;
}
return Q;
}
public short GetQuarter(short ch)
{
short Q=0;
switch (ch)
{
case 1:
if (radFrmDashQ1.Checked)
Q = 1;
else if (radFrmDashQ2.Checked)
Q = 2;
else if (radFrmDashQ3.Checked)
Q = 3;
else
Q = 4;
break;
case 2:
if (radToDashQ1.Checked)
Q = 1;
else if (radToDashQ2.Checked)
Q = 2;
else if (radToDashQ3.Checked)
Q = 3;
else
Q = 4;
break;
default:
Q = 0;
break;
}
return Q;
}
}
This is the code from class Class1
public class Class1
{
public static bool HasErrors()
{
Default xDef = new Default();
bool xErr = False;
if (xDef.GetQuarter(1) > xDef.GetQuarter(2))
xErr = true;
return xErr;
}
}