Module Scope Dim Keyword

Warns about module-level declarations made using the 'Dim' keyword.

 NEW! This inspection is only available in pre-release builds.


Private module variables should be declared using the 'Private' keyword. While 'Dim' is also legal, it should preferably be restricted to declarations of procedure-scoped local variables, for consistency, since public module variables are declared with the 'Public' keyword.

Default severity


Inspection type



The following quickfixes are available for this inspection:


This example should trigger a result

MyModule (StandardModule)
Option Explicit Dim foo As Long ' ...

This example should NOT trigger a result

MyModule (StandardModule)
Option Explicit Private foo As Long ' ...

Rubberduck.CodeAnalysis.Inspections.Concrete.ModuleScopeDimKeywordInspection.cs (Prerelease-v2.5.2.6174)