0

我的班级“联系人”有以下字段:

Private Name As String
Private CurDate As Date
Private Dict As Dictionary

Private Sub Class_Initialize()
    Set Dict = New Dictionary
End Sub
Private Sub Class_Terminate()
    Set Dict = Nothing
End Sub

(这应该在构造函数中Set Dict = New Dictionary吗?)并遵循字典字段的获取属性:

Public Property Get Get_Dict() As Dictionary
    Get_Dict = Dict
End Property

现在在我的代码中我有:

Dim Contact1 As New Contact
Contact1.Set_Contact x, y, z

Dim TempDic As New Dictionary
Set TempDict = Contact1.Get_Dict

它不编译:“参数不是可选的”。如果我在 Get_Dict 属性中显然没有参数,这怎么可能?

4

1 回答 1

0

应该使用:

Public Property Get Get_Dict() As Dictionary
   Set Get_Dict = Dict
End Property

当我们将引用分配给对象时。

于 2012-11-01T19:14:27.567 回答