Object referense not set to instance error 
November 20th, 2005, 02:26 AM
| | | Object referense not set to instance error
I hate this error and usually can find a way to fix it but this one has me
stumped
tColors is an ArrayList
At first I had this:
tColors.Add(ColorsTextBox.Text)
Now I have this:
Dim str As String
str = ColorsTextBox.Text
tColors.Add(str)
Neither one works and both give me the "Object reference not set to an
instance of an object" error. How is str NOT an instance of an object?? It
is clearly defined right above. | 
November 20th, 2005, 02:26 AM
| | | Re: Object referense not set to instance error
Did you use NEW to declare your array list? Your code worked perfectly when
I tried it.
Dim tColors as New ArrayList()
"Stephen" <graybeal@bellatlantic.net> wrote in message
news:%23pUKZQWiDHA.2380@tk2msftngp13.phx.gbl...[color=blue]
> I hate this error and usually can find a way to fix it but this one has me
> stumped
>
> tColors is an ArrayList
>
> At first I had this:
>
> tColors.Add(ColorsTextBox.Text)
>
> Now I have this:
>
> Dim str As String
> str = ColorsTextBox.Text
> tColors.Add(str)
>
> Neither one works and both give me the "Object reference not set to an
> instance of an object" error. How is str NOT an instance of an object??[/color]
It[color=blue]
> is clearly defined right above.
>
>[/color] | 
November 20th, 2005, 02:26 AM
| | | Re: Object referense not set to instance error
"Stephen" <graybeal@bellatlantic.net> scripsit:[color=blue]
> tColors is an ArrayList
>
> At first I had this:
>
> tColors.Add(ColorsTextBox.Text)
>
> Now I have this:
>
> Dim str As String
> str = ColorsTextBox.Text
> tColors.Add(str)
>
> Neither one works and both give me the "Object reference not set to an
> instance of an object" error. How is str NOT an instance of an object?? It
> is clearly defined right above.[/color]
I think the problem is that 'ColorsTextBox' is pointing to 'Nothing'.
Where do you use this code?
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet> | 
November 20th, 2005, 02:27 AM
| | | Re: Object referense not set to instance error
Hi Stephen,
Sherlock Holmes:
When you have eliminated the impossible,
whatever remains - however improbable -
<must> be the truth.
You've eliminated str.
;-)
Regards,
Fergus | 
November 20th, 2005, 02:27 AM
| | | Re: Object referense not set to instance error
I don't know why, but that worked. I've been programming in VB for years
and never really understood the difference between a declaration with and
without New.
Thanks.
"Brian" <nospam@prairie.lakes.com> wrote in message
news:vnpuuo2bjeih94@corp.supernews.com...[color=blue]
> Did you use NEW to declare your array list? Your code worked perfectly[/color]
when[color=blue]
> I tried it.
>
> Dim tColors as New ArrayList()
>
>
>
>
>
> "Stephen" <graybeal@bellatlantic.net> wrote in message
> news:%23pUKZQWiDHA.2380@tk2msftngp13.phx.gbl...[color=green]
> > I hate this error and usually can find a way to fix it but this one has[/color][/color]
me[color=blue][color=green]
> > stumped
> >
> > tColors is an ArrayList
> >
> > At first I had this:
> >
> > tColors.Add(ColorsTextBox.Text)
> >
> > Now I have this:
> >
> > Dim str As String
> > str = ColorsTextBox.Text
> > tColors.Add(str)
> >
> > Neither one works and both give me the "Object reference not set to an
> > instance of an object" error. How is str NOT an instance of an object??[/color]
> It[color=green]
> > is clearly defined right above.
> >
> >[/color]
>
>[/color] | | Thread Tools | Search this Thread | | | |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 220,662 network members.
|