wilslm
asked on
console
Help me outttt
I'm gettin this error message when i tried to run my program :
Unhandled Exception: System.NullReferenceExcept ion: Object reference not set to
an instance of an object.
at ConLib.SetBackgroundColor( ConLib* , UInt16 Color) in d:\documents and sett
ings\tejo\desktop\codes\te st conlib\onlib.cpp:line 22
at main() in d:\documents and settings\tejo\desktop\code s\test conlib\main.cp
p:line 12
Press any key to continue
what is this error telling me?
here is my code from main.cpp:
ConLib* test;
test->SetBackgroundColor(0 );
and here is my code in my function SetBackGroundColor(WORD Color)
void ConLib::SetBackgroundColor (WORD Color)
{
m_BackgroundColor = 0 ;
//combining the colors;
if(Color & ConRed)
{
m_BackgroundColor |= BACKGROUND_RED;
}
if(Color & ConGreen)
{
m_BackgroundColor |= BACKGROUND_GREEN;
}
if(Color & ConBlue)
{
m_BackgroundColor |= BACKGROUND_BLUE;
}
SetConsoleTextAttribute (m_Screen, m_TextColor | m_BackgroundColor);
}
pls help me out. i'm a begginner in using this console thing.
My platform is windows and i'm using Visual C++ .NET
Thank you.
I'm gettin this error message when i tried to run my program :
Unhandled Exception: System.NullReferenceExcept
an instance of an object.
at ConLib.SetBackgroundColor(
ings\tejo\desktop\codes\te
at main() in d:\documents and settings\tejo\desktop\code
p:line 12
Press any key to continue
what is this error telling me?
here is my code from main.cpp:
ConLib* test;
test->SetBackgroundColor(0
and here is my code in my function SetBackGroundColor(WORD Color)
void ConLib::SetBackgroundColor
{
m_BackgroundColor = 0 ;
//combining the colors;
if(Color & ConRed)
{
m_BackgroundColor |= BACKGROUND_RED;
}
if(Color & ConGreen)
{
m_BackgroundColor |= BACKGROUND_GREEN;
}
if(Color & ConBlue)
{
m_BackgroundColor |= BACKGROUND_BLUE;
}
SetConsoleTextAttribute (m_Screen, m_TextColor | m_BackgroundColor);
}
pls help me out. i'm a begginner in using this console thing.
My platform is windows and i'm using Visual C++ .NET
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if you declare a Form like this....
code:
--------------------------
Dim frm As Form1
frm.Show()
'/// this will erro
r-------------------------
you would get that error because you didnt declare it as a NEW form , or as a CAST of a Form.
the correct ways , depending on what you are doing would be like these...
code:---------------------
Dim frm As New Form1()
frm.Show()
'///OR
Dim frm As Form1 = DirectCast(Me.Owner , Form1 ) '/// if form1 was the owner of the Form you call from.
frm.Show()
--------------------------
the same applies to all stuff, like Objects etc... , you must initialize them