Skip to content

VBA130 — Required parameter after Optional

Severity: 🔴 error Category: signature Phase: 2.10

Description

Once a parameter is declared Optional, every parameter after it must also be Optional (the trailing ParamArray aside).

Failing example

Sub S(Optional a As Long, b As Long): End Sub

Compliant example

Sub S(Optional a As Long, Optional b As Long): End Sub

How to fix

Mark the trailing parameters Optional, or move the required ones before the first Optional.


Source: src/rules.py — entry VBA130.