Skip to content

VBA230 — Const initialiser calls a function

Severity: 🔴 error Category: const_expression Phase: 2.5

Description

Const initialisers must be constant expressions — function calls are not allowed.

Failing example

Const X As Long = MsgBox("x")

Compliant example

Const X As Long = 42

How to fix

Replace the call with a literal or another Const reference.


Source: src/rules.py — entry VBA230.