RDC00114 — Implicit array declaration
Severity: Information · Family: RDC (Rubberduck Core analyzers) ·
Raised by: ImplicitArrayDeclarationAnalyzer
A ReDim statement declares the array it re-dimensions.
A ReDim gives an array its dimensions. When its name matches no variable and no constant - of the procedure, the module, another module or a library -
the ReDim declares a new array of that name in the procedure (MS-VBAL §5.4.3.3), under Option Explicit too. A name that is misspelled, or a
ReDim that was meant for an array of another module that is not declared yet, quietly becomes a new array, and the array meant is left as it was.
The diagnostic is an opinion of the analyzer and not a condition of the language: both are legal VBA.
A Dim before the ReDim says that a new array is meant, and gives it its type: Option Explicit then catches a name that is misspelled.
That the name matched nothing is a fact the host vouches for, which knows every module and library the name could have matched. A name the ReDim
hides - a procedure, a module or a function of a library of the same name - is another matter.
How it is raised
| Situation | Example | Resolution |
|---|---|---|
A ReDim of a name nothing declares. |
ReDim totals(1 To 12) |
Declare the array first: Dim totals() As Currency, then ReDim totals(1 To 12). |
See also
ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca