3

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?

Matze
  • 5,100
  • 6
  • 46
  • 69

1 Answers1

2

The only reason would be to allow/support both assignment syntaxes:

set instance.DrawObject = obj

and

instance.DrawObject = obj
Alex K.
  • 171,639
  • 30
  • 264
  • 288
  • 1
    I see; feels a bit odd to me... Found another good explanation about the difference of `Let` and `Set`; just adding the link for completeness: http://stackoverflow.com/questions/5042379/in-vb6-what-is-the-difference-between-property-set-and-property-let – Matze Jul 16 '15 at 11:31
  • The link is important since it explains what the two syntaxes mean. – MarkJ Jul 17 '15 at 12:09