Table of Contents

VBC09333 — Variable required

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

An expression that is not a variable is where a statement requires a variable: a value is to be assigned into it.

MS-VBA reports the same error: Variable required - can't assign to this expression.

This code is raised for the statements whose operands the specification says "MUST be classified as a variable" (MS-VBAL §5.6.1): MidStatementStaticSemantics and FileStatementStaticSemantics.

How it is raised

Situation Example Resolution
The target of a Mid statement is not a variable. Mid("abc", 1) = "x" Assign into a variable that holds the string.
The target of a Line Input #, an Input # or a Get is not a variable. Line Input #1, "x" Read into a variable.
The expression is a constant. Input #1, Limit, for Const Limit = 10 Read into a variable.

Notes

Only an expression that is certainly not a variable is reported: a literal, the result of an operator, and the name of a constant. Which of the others - a member access, an index - is a variable depends on what it resolves to, and is not judged here.

See also


⏮️ VBC09332 Exit Sub not allowed in Function or Property | ⏭️ VBC09334 Access not valid for the file mode


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