Skip to content

VBA160 — Assignment to constant not permitted

Severity: 🔴 error Category: assignment Phase: 2.13

Description

A Const or Enum member is read-only and cannot be assigned to.

Failing example

Const PI As Double = 3.14159
PI = 3

Compliant example

Const PI As Double = 3.14159
Dim r As Double
r = PI

How to fix

Assign to a variable, not a constant or Enum member.


Source: src/rules.py — entry VBA160.