Table of Contents

RDC00205 — Misleading ByRef parameter

Severity: Information  ·  Family: RDC (Rubberduck Core analyzers)  ·  Raised by: MisleadingByRefParameterAnalyzer

ByRef is written on the value parameter of a property Let or Set.

The last parameter of a property Let or Set is the value being assigned, and it is always passed by value (MS-VBAL §5.3.1.7 Property Declarations), whatever the declaration says. A ByRef there reads as if the property could change the variable of the caller, which it cannot. The diagnostic is an opinion of the analyzer and not a condition of the language: it is legal VBA.

The syntax tree keeps the keyword that is written, though the parameter is by value either way (ParameterDeclarationNode.IsByRefIgnored); that is what the analyzer reads. It is a suggestion because removing the keyword does not change what the parameter is.

How it is raised

Situation Example Resolution
The value parameter of a property Let or Set is declared ByRef. Property Let Total(ByRef value As Long) Write ByVal, which is what the parameter is, or remove the keyword.

See also


ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca