Object reference not set to an instance of an object

C

cmdolcet69

I get an Object Reference not set to an instance of an object when my
code is hit on the pfile.GraphicArrowLimits


Public Function AddGraphicArrowLimitsToScreen(ByVal compSelected As
String) As Boolean
Try
If compSelected = "-Blank Entry-" Then
compSelected = String.Empty
End If
Dim intloop As Integer
'If pFile.GraphicArrowLimits.Count = Nothing Then
'Exit Function
'End If
For intloop = 0 To pFile.GraphicArrowLimits.Count - 1
If pFile.GraphicArrowLimits(intloop).CompName =
compSelected And pFile.GraphicArrowLimits(intloop).ShowArrowLimits =
True Then
Return True
End If
Next
Return False

Catch ex As Exception
tListener.AddMethodError(ex)
End Try
End Function




The class I call this Function in the pfile is declared as
Private pFile As PartfileLibrary.Partfile


The actual Partfile Class i call me GraphicArrowLimits
Public GraphicArrowLimits As GraphicArrowLimitList = New
GraphicArrowLimitList

I dont know why this is trigging the error when i have instanciated
the object?????
 
K

kimiraikkonen

I get an Object Reference not set to an instance of an object when my
code is hit on the pfile.GraphicArrowLimits

Public Function AddGraphicArrowLimitsToScreen(ByVal compSelected As
String) As Boolean
        Try
            If compSelected = "-Blank Entry-" Then
                compSelected = String.Empty
            End If
            Dim intloop As Integer
            'If pFile.GraphicArrowLimits.Count = Nothing Then
            'Exit Function
            'End If
            For intloop = 0 To pFile.GraphicArrowLimits.Count - 1
                If pFile.GraphicArrowLimits(intloop).CompName =
compSelected And pFile.GraphicArrowLimits(intloop).ShowArrowLimits =
True Then
                    Return True
                End If
            Next
            Return False

        Catch ex As Exception
            tListener.AddMethodError(ex)
        End Try
    End Function

The class I call this Function in the pfile is declared as
Private pFile As PartfileLibrary.Partfile

The actual Partfile Class i call me GraphicArrowLimits
Public GraphicArrowLimits As GraphicArrowLimitList = New
GraphicArrowLimitList

I dont know why this is trigging the error when i have instanciated
the object?????

"New" keyword is missing somewhere.

Could you try:

Private pFile As New PartfileLibrary.Partfile

or please only post at which code line your project fails clearly.
 
C

cmdolcet69

"New" keyword is missing somewhere.

Could you try:

Private pFile As New PartfileLibrary.Partfile

or please only post at which code line your project fails clearly.

it fails on the line below:
For intloop = 0 To pFile.GraphicArrowLimits.Count - 1

When i add a watch or hover over the pfile.GraphicArrowLimits it says
Object Reference not set to an instance of an object.
 
C

cmdolcet69

"New" keyword is missing somewhere.

Could you try:

Private pFile As New PartfileLibrary.Partfile

or please only post at which code line your project fails clearly.

How can I add a dummy value for the pfile.GraphicArrowLimits ?
 
C

Cor Ligthert[MVP]

cmdolcet,

Be aware that you can get this message to when your programs goes in an
ininity loop and it goes out of memory.

Are you sure that is not happening with your loop?

Cor
 
C

cmdolcet69

cmdolcet,

Be aware that you can get this message to when your programs goes in an
ininity loop and it goes out of memory.

Are you sure that is not happening with your loop?

Cor

I don't think so. If i went into an infinite loop would it not go into
the loop first?... Also when i look at my pfile objects I see that my
GraphicArrowLimits has a value of nothing.
 
R

René Jensen

have you tried to change this
If pFile.GraphicArrowLimits.Count = Nothing Then
Exit Function
End If

to this and leave it in
If pFile.GraphicArrowLimits is Nothing Then
Exit Function
End If

And secondly could it be another thread that messes with your object?
remember that system.timers.timer create a new thread when the tick
event is invoked.

René
 
C

Claes Bergefall

cmdolcet69 said:
The class I call this Function in the pfile is declared as
Private pFile As PartfileLibrary.Partfile

The above will define pFile but will not set it to anything useful (i.e.
it's Nothing at this stage). When/where do you actually assign something to
it? Looks to me like you're forgetting to create the object.

/claes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top