I'm having some trouble of understanding on how to make my own type object. I have two different classes and I would like that my list type to be given the object of the data type.
data Class: (Be aware that this is just a snippet of the code)
Private index As Integer
Private id As String
Private nameID() As String
Private data() As String
Private cnt As Integer
Public Function constructor(value As Integer)
index = 0
cnt = value
id = ""
ReDim nameID(0 To cnt)
ReDim data(0 To cnt)
End Function
Property Let setName(value As String)
nameID(index) = value
End Property
Property Let setData(value As String)
data(index) = value
index = index + 1
End Property
Property Get getName()
getName = nameID
End Property
Property Get getData()
getData = data
End Property
list Class:
Private xArray() As dataStruct
Private index As Integer
Public Function constructor(cnt As Integer)
ReDim xArray(1 To cnt)
Dim num As Integer
For num = 1 To cnt
Set xArray(num) = New dataStruct
'xArray(num).constructor(10)
Next
index = 1
End Function
So the problem I have occurs when I try to get the values from my data class to my list class. I have tried to set them equal each other and assign each value separately but nothing seems to work. I get the "Run-time error '438: Object doesn't support this property or method'. If I try to use the commented code I get past the setID
but when entering setName
it comes a type mismatch but it should be an array of type string.
Property Let addArray(value As dataStruct)
xArray(index) = value
'xArray(index).setID = value.getID
'xArray(index).setName = value.getName
'xArray(index).setData = value.getData
'xArray(index).setCnt = value.getCnt
index = index + 1
End Property
[Edited: Added example of get and set methods]