Table of Contents

RDC00204 — Multiple declarations

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

A Dim, Static, Private, Public or Const statement declares several names.

Each name of such a statement has a type of its own (MS-VBAL §5.4.3.1 Local Variable Declarations), and an As clause that is written once, at the end, is the type of the last name only: in Dim a, b As Long, b is a Long and a is a Variant. The diagnostic is an opinion of the analyzer and not a condition of the language: both are legal VBA.

Several statements on one line, separated by :, are several declarations and are not reported.

That a statement declares several names is a fact of the way it is written: the analyzer reads it off the syntax tree, and makes one finding for each statement. It is a suggestion because splitting the statement does not change what any of the declarations is, as long as each is given the type it already has.

How it is raised

Situation Example Resolution
A variable declaration statement declares more than one name. Dim first, last As String Declare each name in a statement of its own, with its own type.
A constant declaration statement declares more than one constant. Const A = 1, B = 2 Declare each constant in a statement of its own.

See also


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