Skip to content

VBA165 — Invalid use of New keyword

Severity: 🔴 error Category: declaration Phase: 2.13

Description

New requires a creatable class; primitives, Object and Variant cannot be New-ed.

Failing example

Dim x As New Long

Compliant example

Dim c As New Collection

How to fix

Use New only with a class type, or drop New for primitives.


Source: src/rules.py — entry VBA165.