Table of Contents

RDC00202 — Module-scope Dim declaration

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

A module-level variable is declared with Dim.

At the module level Dim declares a Private variable, the same as Private does (MS-VBAL §5.2.3 Module Declarations); Dim is the keyword of a local variable, and Private and Public state what a module-level one is. The diagnostic is an opinion of the analyzer and not a condition of the language: both are legal VBA.

That a statement is written with Dim is a fact of the way it is written: the analyzer reads it off the syntax tree, and makes one finding for each statement, however many variables it declares. It is a suggestion because Private does not change what the variable is.

How it is raised

Situation Example Resolution
A variable is declared with Dim outside of any procedure. Dim total As Long Write Private, or Public if the variable is meant to be accessible from other modules.

See also


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