问题
In an older project I found a property declaration in a class module which looks like the following...
Public Property Get DrawObject() As Object
Set DrawObject = m_obj
End Property
Public Property Let DrawObject(obj As Object)
Set m_obj = obj
Draw
End Property
Public Property Set DrawObject(obj As Object)
Set m_obj = obj
Draw
End Property
I would like to know why the DrawObject
property has both a Let
and Set
accessor defined; what could be the purpose of such a declaration?
回答1:
The only reason would be to allow/support both assignment syntaxes:
set instance.DrawObject = obj
and
instance.DrawObject = obj
来源:https://stackoverflow.com/questions/31448603/why-would-one-declare-both-a-let-and-set-property-accessor-in-vb6