473,505 Members | 15,212 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

¿ Object reference not set to an instance of an object. ?

I am getting this error (below) and do not understand how or why.
Perhaps part of the problem is that I am not experienced in OO
programming.

" An unhandled exception of type 'System.NullReferenceException'
occurred in GraphPlay2.exe

Additional information: Object reference not set to an instance of an
object."

This occurs in a very short Sub at the statement indicated ...

Private Sub ReadData()

Dim sInFileName As String = "allfiles.csv"
Dim srInFile As System.IO.StreamReader
Dim DebugTBLines() As String 'for setting TextBox Lines
srInFile = System.IO.File.OpenText(sInFileName)

Do
sInBuf = srInFile.ReadLine()
'MessageBox.Show("Record is """ & sInBuf & """")
If sInBuf Is Nothing Then Exit Do
RecordNumber += 1
If RecordNumber >= MaxFiles Then
MessageBox.Show("Too Damn Many Files; Giving Up")
Close()
Else : ParseInput()
DebugTBLines(RecordNumber) =
FileInfo(RecordNumber).Name '<<<< Error Happens Here !!!
End If

Loop
srInFile.Close()
TextBox1.Lines = DebugTBLines
End Sub 'ReadData

The Watch Window proves that RecordNumber has a value, 0, and that
FileInfo(0).Name has a value.

I'll appreciate any help/adivce/pointers you can offer.

Thanks, Bob
Nov 21 '05 #1
3 1126
Bob,
Dim DebugTBLines() As String 'for setting TextBox Lines DebugTBLines is nothing, you need to define a size for the array.

I would probably simply initialize it to MaxFiles, as that seems to be your
limit.

Dim DebugTBLines(MaxFiles) As String 'for setting TextBox Lines

This allows DebugTBLines to have MaxFiles + 1 entries as MaxFiles is the
upper bound of the array, with the lower bound being 0.

Hope this helps
Jay

"eBob.com" <eB******@totallyfakeisp.com> wrote in message
news:06********************************@4ax.com...I am getting this error (below) and do not understand how or why.
Perhaps part of the problem is that I am not experienced in OO
programming.

" An unhandled exception of type 'System.NullReferenceException'
occurred in GraphPlay2.exe

Additional information: Object reference not set to an instance of an
object."

This occurs in a very short Sub at the statement indicated ...

Private Sub ReadData()

Dim sInFileName As String = "allfiles.csv"
Dim srInFile As System.IO.StreamReader
Dim DebugTBLines() As String 'for setting TextBox Lines
srInFile = System.IO.File.OpenText(sInFileName)

Do
sInBuf = srInFile.ReadLine()
'MessageBox.Show("Record is """ & sInBuf & """")
If sInBuf Is Nothing Then Exit Do
RecordNumber += 1
If RecordNumber >= MaxFiles Then
MessageBox.Show("Too Damn Many Files; Giving Up")
Close()
Else : ParseInput()
DebugTBLines(RecordNumber) =
FileInfo(RecordNumber).Name '<<<< Error Happens Here !!!
End If

Loop
srInFile.Close()
TextBox1.Lines = DebugTBLines
End Sub 'ReadData

The Watch Window proves that RecordNumber has a value, 0, and that
FileInfo(0).Name has a value.

I'll appreciate any help/adivce/pointers you can offer.

Thanks, Bob

Nov 21 '05 #2
Jeez, what a dumb question. Sorry for asking it. Thanks for your
help Jay.

Bob

On Wed, 6 Oct 2004 11:46:27 -0500, "Jay B. Harlow [MVP - Outlook]"
<Ja************@msn.com> wrote:
Bob,
Dim DebugTBLines() As String 'for setting TextBox Lines

DebugTBLines is nothing, you need to define a size for the array.

I would probably simply initialize it to MaxFiles, as that seems to be your
limit.

Dim DebugTBLines(MaxFiles) As String 'for setting TextBox Lines

This allows DebugTBLines to have MaxFiles + 1 entries as MaxFiles is the
upper bound of the array, with the lower bound being 0.

Hope this helps
Jay

"eBob.com" <eB******@totallyfakeisp.com> wrote in message
news:06********************************@4ax.com.. .
I am getting this error (below) and do not understand how or why.
Perhaps part of the problem is that I am not experienced in OO
programming.

" An unhandled exception of type 'System.NullReferenceException'
occurred in GraphPlay2.exe

Additional information: Object reference not set to an instance of an
object."

This occurs in a very short Sub at the statement indicated ...

Private Sub ReadData()

Dim sInFileName As String = "allfiles.csv"
Dim srInFile As System.IO.StreamReader
Dim DebugTBLines() As String 'for setting TextBox Lines
srInFile = System.IO.File.OpenText(sInFileName)

Do
sInBuf = srInFile.ReadLine()
'MessageBox.Show("Record is """ & sInBuf & """")
If sInBuf Is Nothing Then Exit Do
RecordNumber += 1
If RecordNumber >= MaxFiles Then
MessageBox.Show("Too Damn Many Files; Giving Up")
Close()
Else : ParseInput()
DebugTBLines(RecordNumber) =
FileInfo(RecordNumber).Name '<<<< Error Happens Here !!!
End If

Loop
srInFile.Close()
TextBox1.Lines = DebugTBLines
End Sub 'ReadData

The Watch Window proves that RecordNumber has a value, 0, and that
FileInfo(0).Name has a value.

I'll appreciate any help/adivce/pointers you can offer.

Thanks, Bob


Nov 21 '05 #3
Bob,
I don't consider it a dumb question, as most or all of us do it once or
twice & miss the fact we did...

Just a thought
Jay

"eBob.com" <eB******@totallyfakeisp.com> wrote in message
news:ie********************************@4ax.com...
Jeez, what a dumb question. Sorry for asking it. Thanks for your
help Jay.

Bob

On Wed, 6 Oct 2004 11:46:27 -0500, "Jay B. Harlow [MVP - Outlook]"
<Ja************@msn.com> wrote:
Bob,
Dim DebugTBLines() As String 'for setting TextBox Lines

DebugTBLines is nothing, you need to define a size for the array.

I would probably simply initialize it to MaxFiles, as that seems to be
your
limit.

Dim DebugTBLines(MaxFiles) As String 'for setting TextBox Lines

This allows DebugTBLines to have MaxFiles + 1 entries as MaxFiles is the
upper bound of the array, with the lower bound being 0.

Hope this helps
Jay

"eBob.com" <eB******@totallyfakeisp.com> wrote in message
news:06********************************@4ax.com. ..
I am getting this error (below) and do not understand how or why.
Perhaps part of the problem is that I am not experienced in OO
programming.

" An unhandled exception of type 'System.NullReferenceException'
occurred in GraphPlay2.exe

Additional information: Object reference not set to an instance of an
object."

This occurs in a very short Sub at the statement indicated ...

Private Sub ReadData()

Dim sInFileName As String = "allfiles.csv"
Dim srInFile As System.IO.StreamReader
Dim DebugTBLines() As String 'for setting TextBox Lines
srInFile = System.IO.File.OpenText(sInFileName)

Do
sInBuf = srInFile.ReadLine()
'MessageBox.Show("Record is """ & sInBuf & """")
If sInBuf Is Nothing Then Exit Do
RecordNumber += 1
If RecordNumber >= MaxFiles Then
MessageBox.Show("Too Damn Many Files; Giving Up")
Close()
Else : ParseInput()
DebugTBLines(RecordNumber) =
FileInfo(RecordNumber).Name '<<<< Error Happens Here !!!
End If

Loop
srInFile.Close()
TextBox1.Lines = DebugTBLines
End Sub 'ReadData

The Watch Window proves that RecordNumber has a value, 0, and that
FileInfo(0).Name has a value.

I'll appreciate any help/adivce/pointers you can offer.

Thanks, Bob

Nov 21 '05 #4

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

Similar topics

28
20272
by: Daniel | last post by:
Hello =) I have an object which contains a method that should execute every x ms. I can use setInterval inside the object construct like this - self.setInterval('ObjectName.methodName()',...
6
22489
by: Martin | last post by:
I'd like to be able to get the name of an object instance from within a call to a method of that same object. Is this at all possible? The example below works by passing in the name of the object...
15
6718
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...
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
1852
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...
12
5505
by: Andrew Poulos | last post by:
With the following code I can't understand why this.num keeps incrementing each time I create a new instance of Foo. For each instance I'm expecting this.num to alert as 1 but keeps incrementing. ...
6
2467
by: Shailen Sukul | last post by:
Observed a weird behaviour with object references. See code listing below: using System; using System.Collections.Generic; using System.Text; namespace PointerExceptionTest { /*
14
2370
by: Philipp Reif | last post by:
Hi all, I've got a little hole in my head concerning references. Here's what I'm trying to do: I'm calling a function, passing the reference of a business object for editing. The function clones...
3
2754
by: User1014 | last post by:
A global variable is really just a property of the "Global Object", so what does that make a function defined in the global context? A method of the Global Object? ...
2
2621
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
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7303
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
7367
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
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5028
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
3187
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...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
407
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.