Skip to content

VBA240 — Arithmetic operator between string and numeric literal

Severity: 🔴 error Category: operator_type Phase: 2.4

Description

Operators like -, *, /, \, ^, Mod require numeric operands. Use & for string concatenation.

Failing example

x = "abc" - 1

Compliant example

x = "value: " & 1

How to fix

Use & for concatenation. + is bidirectional in VBA but can silently coerce — prefer & for strings.


Source: src/rules.py — entry VBA240.