Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object reference not set to an instance of an object.

Status
Not open for further replies.

suba25

Technical User
Dec 9, 2002
1
US
An array has been decalared ad
String[] Troubledesc;

The trouticketrequest is the object of the request

if (TextBox8.Text != "")
{
trouticketrequest.TroubleDescCode[0]= TextBox8.Text;
}

when TextBox8 has some values it is results in "Object reference not set to an instance of an object."


could u please help me
 
I don't know which language that is, but from the looks of it, it looks like C# (or maybe Java, don't have no experience with that). Haven't done much with C#, but from what the error states, I assume that you declared some object (trouticketrequest) without actually instantiating it, or assign it to an existing object.

In VB this would be something like this:

dim trouticketrequest as SomeObject '//Dimmed, but not yet an actual object.

trouticketrequest.TroubleDescCode(0)=TextBoxB.Text '//This will result in an error.

'//This won't
set trouticketrequest = new SomeObject
trouticketrequest.TroubleDescCode(0)=TextBoxB.Text

'//And this won't either:
set trouticketrequest = objAlreadyExistingObject '//The name says it all...
trouticketrequest.TroubleDescCode(0)=TextBoxB.Text


Greetings,
Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top