I am having a problem setting an object property which is itself an object.
The error code (Error 91) suggests an object variable is not set. I know I have
declared and assigned a valid reference to the object being stored and the object doing the storing.
So I am wondering if the problem is that I do not understand object scope wherein maybe one of the objects loses scope.
Any suggestions are appreciated.
/code snippet
‘ for as many Measurements exist in FieldData
With Ptr2OpnWrkBk
With Ptr2FDWrkSht
For Row = DataRowStart To NumofRows
' instantiate a Measurement Obj
Set Ptr2FieldData = New MeasurementObj '
' instantiate a coordinates obj
Set FieldDataCoordinates = New CoordinatesObj
' read MeasurementData into the MeasurementObj
Ptr2FieldData.ID = Ptr2FDWrkSht.Cells(Row, ElevationIDColumn).value
/code region of interest
FieldDataCoordinates.X = Ptr2FDWrkSht.Cells(Row, X_CoordinateColumn).value
FieldDataCoordinates.Y = Ptr2FDWrkSht.Cells(Row, Y_CoordinateColumn).value
Ptr2FieldData.Coordinates = FieldDataCoordinates
/end code region of interest
Ptr2FieldData.Elevation = Ptr2FDWrkSht.Cells(Row, ElevationColumn).value
Ptr2FieldData.ElevationType = Ptr2FDWrkSht.Cells(Row, ElevationTypeColumn).value
' add Ptr2FDo to FieldDataCollection
Call Ptr2FDc.Add(Ptr2FieldData)
Next
End With
End With
/end code
/code of MeasurementObj in which the instantiated object throws an error
Option Explicit
' MeasurementObj
Private PMeasurementID As Long
Private PMeasurementElevation As Double
Private PMeasurementElevationType As String
Private PMeasurementCoordinates As CoordinatesObj
Public Property Let ID(value As Long)
PMeasurementID = value
End Property
Public Property Get ID() As Long
ID = PMeasurementID
End Property
Public Property Let Elevation(value As Double)
PMeasurementElevation = value
End Property
Public Property Get Elevation() As Double
Elevation = PMeasurementElevation
End Property
Public Property Let ElevationType(value As String)
PMeasurementElevationType = value
End Property
Public Property Get ElevationType() As String
ElevationType = PMeasurementElevationType
End Property
/CODE IN WHICH ERROR OCCURS
Public Property Let Coordinates(value As CoordinatesObj)
PMeasurementCoordinates = value
End Property
/END CODE IN WHICH ERROR OCCURS
/code continued
Public Property Get Coordinates() As CoordinatesObj
Coordinates = PMeasurementCoordinates
End Property
/end of code
Bookmarks