gpt4 book ai didi

vba - 在 VBA 中设置对象的集合属性

转载 作者:行者123 更新时间:2023-12-02 09:31:46 24 4
gpt4 key购买 nike

我有一个以 Collection 作为属性的类,

债券类别

Private pBondiSIN As String
Private pBroker As Collection

''''''''''''''''''''''
' BondiSIN property
''''''''''''''''''''''
Public Property Get BondiSIN() As String
BondiSIN = pBondiSIN
End Property
Public Property Let BondiSIN(Value As String)
pBondiSIN = Value
End Property

''''''''''''''''''''''
' Broker property
''''''''''''''''''''''
Public Property Get Broker() As Collection
Broker = pBroker
End Property
Public Property Let Broker(Value As Collection)
pBroker = Value
End Property

我这样调用它:

Set tempBond = New Bond
tempBond.Broker = New Collection => Gives me a error as Wrong number of Arguments or Invalid property assignment

不知道如何解决这个错误。需要一些帮助。

最佳答案

熟悉Set keyword

Public Property Set Broker(Value As Collection)
Set pBroker = Value
End Property

Set tempBond.Broker = New Collection

关于vba - 在 VBA 中设置对象的集合属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32497191/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com