Table of Contents

VBC09305 — Invalid ParamArray use

Severity: Error  ·  Family: VBC (static semantics / abstract syntax tree)  ·  Source metadata: VBCompileErrorInfo

A ParamArray parameter is passed to a ByRef parameter of a procedure of your own.

A ParamArray holds the values the call collected, one for each argument written after the others. It is not a variable of the caller's, so there is nothing a ByRef parameter could change through it (RD-VBAL §5.3.1.11 Procedure Invocation Argument Processing). Putting it in parentheses does not help: Inner (p) is refused all the same.

MS-VBA reports the same error: Invalid ParamArray use.

This code is raised by ParamArrayStaticSemantics.

How it is raised

Situation Example Resolution
A ParamArray is the argument of a ByRef parameter, declared or implicit, of a procedure, a function or a member of a class of your own. Sub Outer(ParamArray p() As Variant) calls Inner p, where Sub Inner(a As Variant) Declare the parameter ByVal: Sub Inner(ByVal a As Variant).
The procedure is meant to read the values one by one. Total p, where Function Total(values() As Variant) Declare the parameter ByVal values As Variant, or pass the ParamArray on to another one: Function Total(ParamArray values() As Variant).

These compile: passing the ParamArray to a ByVal parameter, to another ParamArray, or to a function of the standard library (IsMissing(p)), and passing one of its elements (Inner p(0)).

See also


⏮️ VBC09304 Invalid use of object | ⏭️ VBC09306 Invalid ReDim


ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca