RDC11046: Let through a Variant property or function
Severity: Warning · Family: RDC (Rubberduck Core analyzers) ·
Raised by: LetThroughAVariantGetOrFunctionAnalyzer
A Let statement assigns a value to a Property Get declared Variant that has no Property Let, or to a function declared Variant, outside the
member's own body.
MS-VBAL §5.4.3.8 raises error 451 for the property and error 450 for the function. RD-VBA does what MS-VBA does (observed in Excel): it calls the member, and assigns the value to the default member of the object it returns. When it returns no object, the statement raises error 424.
' Holder: Property Get Item() As Variant, no Property Let
h.Item = 5 ' MS-VBAL: error 451; RD-VBA and MS-VBA: the default member of the object Item returns is 5
How it is raised
| Situation | Example | What to do |
|---|---|---|
| The value is meant for the object the member returns. | h.Item = 5, where Item returns a Range |
Name the member of that object: h.Item.Value = 5. |
| The value is meant for the member itself. | h.Item = 5, where Item returns a number |
Give the class a Property Let Item. |
See also
- RD-VBAL §5.4.3.8 Let Statement
- RDC11045: Let through a default member with no Property Let
- RD-VBAL §2.6.4 Rubberduck Core Diagnostics
ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca