Skip to content

VBA182 — Deftype statement must precede declarations

Severity: 🔴 error Category: placement Phase: 3.7

Description

DefInt/DefStr/… statements must appear before any variable, constant, type or procedure declaration in the module.

Failing example

Dim x As Long
DefInt A-Z

Compliant example

DefInt A-Z
Dim x As Long

How to fix

Move the DefXxx statement to the top of the module, after Option but before any declaration.


Source: src/rules.py — entry VBA182.