Why would one declare both a Let and Set property accessor in VB6

偶尔善良 提交于 2019-12-10 17:57:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!