Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 15th, 2005, 1:13 PM   #1
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
No Object Instance?

I just had a lot of help with this. This is the MOST IRRITATING thign i have ever done (Move from C++ to C#). My prog compiles fine but crashes at runtime when user hits the enter Key.

Declaration on Form:
[PHP]
DIRCClient dircClient=new DIRCClient();
[/PHP]

Overloaded Form Constructor:
[PHP]
public frmStatus(DIRCClient DircClient)
{
InitializeComponent();

dircClient=DircClient;
}
[/PHP]

Function Using Passed Object:
[PHP]
private void txtStatusInput_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode==Keys.Enter) //was enter pressed?
{
if(!dircClient.b_conStatus)
{
txtStatusWin.Text+=dircClient.s_msgErrSymbol+" not connected"+'\n';
}
else
{
txtStatusWin.Text+=txtStatusInput.Text+'\n';
txtStatusInput.Text=""; //clear the input box
}
}
}
[/PHP]

ERROR:
[PHP]
An unhandled exception of type 'System.NullReferenceException' occured

Additional Info:
Object reference not set to an instance of an object
[/PHP]

this makes no sense to me... i seem to have set it to an instance?
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Old Dec 15th, 2005, 4:21 PM   #2
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
And where is the line where the form is instantiated?
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Old Dec 15th, 2005, 4:38 PM   #3
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
/me shoots himself in the head - thanks a ton Dameon, thats all you had to say. Do you mind if i put your name is my title as so?
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Old Dec 15th, 2005, 5:33 PM   #4
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
A cult, aye? Fair enough.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Old Dec 15th, 2005, 5:59 PM   #5
OpenLoop
Expert Programmer
 
OpenLoop's Avatar
 
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4 OpenLoop is on a distinguished road
Quote:
Originally Posted by Kilo
This is the MOST IRRITATING thing i have ever done (Move from C++ to C#).
if all you do is windows programming, it's going to pay off. I had a similar experience with C#'s multi-dimentional arrays:

in c++, i would do:
int x[3][3];       //declares a 3x3 array
I tried the same thing in C# and got a compile error until i found a form that works(by trial and error)
 int[][] x;
But this was a Jagged array which is an array of arrays that can have different sizes, and not what i wanted.

It wasn't until i took a class in C# that i figured out how to declare a rectangular array
int[,] x = new int[3,3];
OpenLoop is offline   Reply With Quote
Old Dec 15th, 2005, 6:51 PM   #6
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
What does the comma stand for? Yea I'm completely self taught through trial/error in VB && C++. But i found this forum and made a bad habit of asking for help on every little thing that doesn't work (that i normally do in cpp).
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Old Dec 15th, 2005, 7:06 PM   #7
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
It is saying a 3x3 array of ints rather than an array of 3 arrays of 3 ints.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Old Dec 15th, 2005, 10:11 PM   #8
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
hmmm i understand:
[PHP]
int[3,3];
[/PHP]

this comma i don't understand:
[PHP]
int[,]
[/PHP]

or is that just stating that you are creating a 2 dimensional array?
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Old Dec 16th, 2005, 7:35 AM   #9
OpenLoop
Expert Programmer
 
OpenLoop's Avatar
 
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4 OpenLoop is on a distinguished road
Quote:
Originally Posted by Kilo
or is that just stating that you are creating a 2 dimensional array?
exactly. one is definition, the other is instantiating.
OpenLoop is offline   Reply With Quote
Old Dec 16th, 2005, 8:07 AM   #10
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Perhaps you should read the last link in your own sig?
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:37 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC