设置自定义对象参数时,堆栈空间不足错误

时间:2018-08-01 10:08:39

标签: vba excel-vba

我有一个名为Service的自定义类模块,带有字符串参数。 我通过创建对象this_service来实例化类,如下所示:

Dim this_service As Service
Set this_service = New Service

然后我尝试将参数设置为任何字符串值,例如:

this_service.Key = "HELLO"

运行宏时,我收到28运行时错误,栈空间不足。

在我的类模块Service中,我具有以下参数定义和方法调用:

Private pKey As String

Public Property Get Key() As String
    Key = pKey
End Property

Public Property Let Key(Value As String)
    Key = Value
End Property

我看不到任何会导致运行时错误的原因吗?

1 个答案:

答案 0 :(得分:0)

Public Property Let中,它应该是:

pKey = Value

现在,它以递归方式(无限期)调用设置器。

相关问题