RDC11047: Object assigned with Let to an object property
Severity: Warning · Family: RDC (Rubberduck Core analyzers) ·
Raised by: ObjectLetToObjectPropertyAnalyzer
A Let assignment gives an object to a property whose value parameter is a class or Object.
RD-VBA passes the property the object itself, as MS-VBA does, the way a Set would pass it. An object of another class than the parameter's is
run-time error 13.
MS-VBAL §5.5.1.1 Static semantics
makes the Let a type mismatch instead, and
MS-VBAL §5.4.3.8 Let Statement
with MS-VBAL §5.5.1.2.13 Let-coercion to and from a class or Object or Nothing
evaluates the object as its default member's value: run-time error 424, or 91 for Nothing.
Dim h As New Holder ' Property Let Picture(ByVal v As Object)
Dim p As Object
Set p = LoadPicture("logo.bmp")
h.Picture = p ' h receives the picture object itself
The warning is raised where the value is declared as an object (a class, or Object) and the property is bound early. A Variant that holds an
object at run time, and a property called late, are not reported.
How it is raised
| Situation | Example | Resolution |
|---|---|---|
| The property is meant to receive the object. | h.Picture = p |
Assign it with Set: declare a Property Set and write Set h.Picture = p. |
| The property is meant to receive the default member's value. | h.Picture = p |
Name the default member, and give the property a value parameter of that type. |
See also
ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca