所以我有两个类模块,ClassA 和 ClassB,以及一个模块中的子模块,我尝试将 B 类中的对象添加到 ClassA 中对象的属性中。
根据 VBE Glossary,类是对象,属性集语句可以添加对象类型,所以这似乎应该是可能的。但是,当我运行测试子时,我收到“对象变量或未设置块变量”错误
子:
Sub test()
Dim Class_A_Object As ClassA
Dim Class_B_Object As ClassB
Set Class_A_Object = New ClassA
Set Class_B_Object = New ClassB
Class_B_Object.Class_B_Property = 42
Class_A_Object.Class_A_Property = Class_B_Object
End Sub
A类:
Private a_Class_A_Property As Object
Public Property Set Class_A_Property(pClass_A_Property As Object)
a_ClassA_Property = pClass_A_Property
End Property
Public Property Get Class_A_Property() As Object
Class_A_Property = a_Class_A_Property
End Property
B类:
Private b_Class_B_Property As Integer
Public Property Let Class_B_Property(pClass_B_Property As Integer)
b_Class_B_Property = pClass_B_Property
End Property
Public Property Get Class_B_Property() As Integer
Class_B_Property = b_Class_B_Property
End Property