Skip to content

VBA370 — Constant/array/Declare as Public member of object module

Severity: 🔴 error Category: placement Phase: 3.10

Description

Constants, arrays and Declare statements cannot be Public members of an object module (Class / Form). They are only legal in standard modules, or as Private members.

Failing example

' in a .cls:
Public Const MAX As Long = 10

Compliant example

' in a .cls:
Private Const MAX As Long = 10

How to fix

Move it to a standard module, or mark it Private and expose it via a Property Get.


Source: src/rules.py — entry VBA370.