chambois
09-08-2009, 09:08 PM
Hey there,
I have a class ('MyClass') that has an array ('myArr') of a custom data type. When I try to set the value of one of the variables in the custom data type, it doesn't get set (or saved). The layout for these three pieces of the puzzle is the following:
MyClass
''' MyClass
Private pMyArr() As customType
' return whole array
Public Property Get myArrs() As customType
myArrs = pMyArr
End Property
' return element of array
Public Property Get myArr(Index As Integer) As customType
myArr = pMyArr(Index)
End Property
Public Property Let myArr(index As Integer, Value As customType)
pMyArr(index) = Value
End Property
CustomType
''' CustomType
Public Type customType
myVar_1 As String
myVar_2 As String
End Type
'--------
Test
''' test
Dim myObj As MyClass
Set myObj = New MyClass
...
For i = 0 To 4
myObj.myArr(i).myVar_1 = "Hello" ' doesn't set
myObj.myArr(i).myVar_2 = "world" ' doesn't set
Next i
I was wondering if anyone can tell me why that code doesn't work and/or if there is a better way to go about it.
Any help would be much appreciated
With Thanks,
Matt
I have a class ('MyClass') that has an array ('myArr') of a custom data type. When I try to set the value of one of the variables in the custom data type, it doesn't get set (or saved). The layout for these three pieces of the puzzle is the following:
MyClass
''' MyClass
Private pMyArr() As customType
' return whole array
Public Property Get myArrs() As customType
myArrs = pMyArr
End Property
' return element of array
Public Property Get myArr(Index As Integer) As customType
myArr = pMyArr(Index)
End Property
Public Property Let myArr(index As Integer, Value As customType)
pMyArr(index) = Value
End Property
CustomType
''' CustomType
Public Type customType
myVar_1 As String
myVar_2 As String
End Type
'--------
Test
''' test
Dim myObj As MyClass
Set myObj = New MyClass
...
For i = 0 To 4
myObj.myArr(i).myVar_1 = "Hello" ' doesn't set
myObj.myArr(i).myVar_2 = "world" ' doesn't set
Next i
I was wondering if anyone can tell me why that code doesn't work and/or if there is a better way to go about it.
Any help would be much appreciated
With Thanks,
Matt