Table of Contents

VBC09361 — ByRef argument type mismatch

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

A variable is passed to a ByRef parameter of another type.

A ByRef parameter is another name for the variable passed to it, and is declared as a type: a variable of another type cannot be it. A Variant parameter takes a variable of any type.

MS-VBA reports the same error, with the same message (recorded in Excel).

This code is raised by ObjectValueStaticSemantics, where the arguments of a call are matched to its parameters.

How it is raised

Situation Example Resolution
An Integer variable to a ByRef Long parameter. Dim i As Integer … TakesLong i Declare the variable as the parameter's type, declare the parameter ByVal, or pass the argument in parentheses: TakesLong (i), a value that is copied.
A Variant variable to a ByRef Long parameter. Dim v As Variant … TakesLong v The same.

Notes

A member of an enumeration is a Long: a variable of an enumeration is passed to a ByRef Long parameter, and the other way around.

See also


⏮️ VBC09360 Can't assign to array | ⏭️ VBC09362 Type mismatch: array or user-defined type expected


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