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 gkittelson 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. Error

Status
Not open for further replies.

KKW123

Programmer
Jul 26, 2013
2
US
I have created a structure in a Module:

Code:
Structure CTPParm
        Dim Color As Long
        Dim LineWeight As Integer
        Dim Title As String
        Dim Position As Long
        Dim AxisIndex As Integer
End Structure

Structure Graph
        Public Shared AxisConfiguration As AxisConfig
        Public Shared LegendConfiguration As LegendConfig
        <VBFixedArray(48)> Shared TraceConfiguration() As CTPParm
        Public Sub Initialize()
            ReDim TraceConfiguration(48)
        End Sub
    End Structure

The AxisConfiguration & LegendConfiguration work properly.
The TraceConfiguration(48) when used causes the error

My intention is such that usage is as follows:
Graph.TraceConfiguration(bb).AxisIndex = 1

The error generated is "Object reference not set to an instance of an object.", and refers to a line similar to the previous line of text.

I'm pretty sure it has to do with the <VBFixedArray(48)> Shared TraceConfiguration() As CTPParm line of code.

Incidentally, the CTPParm structure is used by other structures and works fine.

I can't figure out how to fix this.
Any assistance and/or insight would be greatly appreciated!

Thanks!

 
Turns out this is the fix:

Code:
Structure Graph
        Dim Axis As Integer
        Public Shared AxisConfiguration As AxisConfig
        Public Shared LegendConfiguration As LegendConfig
        <VBFixedArray(48)> Shared TraceConfiguration() As CTPParm
        Shared Sub New()
            ReDim TraceConfiguration(48)
        End Sub
End Structure
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top