473,499 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.
Nov 20 '05 #1
4 2003
Did you use NEW to declare your array list? Your code worked perfectly when
I tried it.

Dim tColors as New ArrayList()

"Stephen" <gr******@bellatlantic.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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.

Nov 20 '05 #2
"Stephen" <gr******@bellatlantic.net> scripsit:
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.


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>
Nov 20 '05 #3
Hi Stephen,

Sherlock Holmes:
When you have eliminated the impossible,
whatever remains - however improbable -
<must> be the truth.

You've eliminated str.

;-)

Regards,
Fergus
Nov 20 '05 #4
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" <no****@prairie.lakes.com> wrote in message
news:vn************@corp.supernews.com...
Did you use NEW to declare your array list? Your code worked perfectly when I tried it.

Dim tColors as New ArrayList()

"Stephen" <gr******@bellatlantic.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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.


Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
10516
by: Pkpatel | last post by:
Hi, I keep getting this error every time I try to load crystalreportviewer on a webform with a dataset. Here is the error: -------------------------------------------------------- Server...
4
3568
by: Daniel Köster | last post by:
Is there someone who has got some tips on how to convert text encoded with character referense ({) to unicode or uft-8 format using VB.net? Is there a function or something that can help with the...
15
6715
by: Carlos Lozano | last post by:
Hi, What is the right way to create an OCX COM component. The component is already registerred, but can't create an instance. I am using the reference to the interop module created. If I use...
18
28708
by: Microsoft | last post by:
When I try this in my code I alwas get an errormessage: "Object reference not set to an instance of an object" Dim g As System.Drawing.Graphics g.DrawString("Test", New Font("Arial", 12,...
3
4198
by: Adam | last post by:
We have a web site that uses .vb for the web pages and .cs for a class module. We are getting the error in .NET 2.0 and VS 2005 beta 2. It does work with .NET 1.1. When trying to access a page...
4
1850
by: Luke Matuszewski | last post by:
Here are some questions that i am interested about and wanted to here an explanation/discussion: 1. (general) Is the objectness in JavaScript was supported from the very first version of it (in...
0
1842
by: cnSoftware | last post by:
I come across this problem during my recent project and even now I am still be puzzled by it. So I paste the procedure here. I wish you can figure out where I am wrong or missing. The sample...
11
3793
by: Kevin Prichard | last post by:
Hi all, I've recently been following the object-oriented techiques discussed here and have been testing them for use in a web application. There is problem that I'd like to discuss with you...
2
2619
by: Ralph | last post by:
Hi I don't understand why it's not working: function schedule(imTop){ this.tdImagesTop = imTop; } schedule.prototype.selectEl = function() { alert(this.tdImagesTop);
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7229
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5485
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4921
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3108
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
311
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.