I am having a problem setting an object property which is itself an object.
Can someone help me understand the error. Perhaps I am not understanding how to use objects in objects
Here is the code in which the attempt is made to set the property. The green font is explanatory text.
The orange text is where I set the properties of a CoordinatesObj. That code works.
The code red text fails in the setting of the property in the object pointed to by Ptr2FieldData
Below this code, after the asterics, is the code of the object, MeasurementObj in which the code fails with a run time error (Run-time error ‘91’ Object variable or with block variable not set). I have used red text to indicate the exact line of code that is failing within MeasurementObj
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
FieldDataCoordinates.X = Ptr2FDWrkSht.Cells(Row, X_CoordinateColumn).value
FieldDataCoordinates.Y = Ptr2FDWrkSht.Cells(Row, Y_CoordinateColumn).value
Ptr2FieldData.Coordinates = FieldDataCoordinates
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
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
Public Property Let Coordinates(value As CoordinatesObj)
PMeasurementCoordinates = value
End Property
Public Property Get Coordinates() As CoordinatesObj
Coordinates = PMeasurementCoordinates
End Property
Bookmarks