1

I have a following property in MyClass2:

 Private MyClass1Array(1 To 4) As MyClass1

where MyClass1 is another class I have defined. I don't know how to adress this property: it can't be set public, so I wrote this in MyClass2 module:

Public Property Let SetMyClass1Array(i As Integer, c As MyClass1)
    MyClass1Array(i) = c
End Property

Public Property Get GetMyClass1Array(i As Integer) As MyClass1
    GetMyClass1Array = MyClass1Array(i)
End Property

But this also doesn't work. How to write this properties correctly? Thanks!

1 Answer 1

3

When you work with Class-objects, you need to use Set as you handle object-references, not primitive data-type values.

Public Property Let SetMyClass1Array(i As Integer, c As MyClass1)
    Set MyClass1Array(i) = c
End Property

Public Property Get GetMyClass1Array(i As Integer) As MyClass1
    Set GetMyClass1Array = MyClass1Array(i)
End Property
Sign up to request clarification or add additional context in comments.

1 Comment

+1 there is also property set instead of let to allow set x.SetMyClass1Array(a) = b

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.