Table of Contents

VBC09355 — Function call on left-hand side of assignment must return Variant or Object

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

A call of a function is assigned.

A call of a function is a value, which cannot be assigned. Assigning one assigns the default member of the object it returns - which only a function that returns an object, or a Variant, can have.

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

This code is raised by StatementStaticSemanticsEvaluator.

How it is raised

Situation Example Resolution
A function that returns a Long. Total() = 1 Assign a variable, or give the function a parameter that it assigns.
The same, by its name alone, outside its own body: a function of the workspace, of the library, or a Declare. Total = 1 in another procedure, Left$ = "x" The same.
A function of an object, with or without arguments. c.Count = 3 of a Collection Assign the property the object has for it, if it has one.

Notes

In its own body, a function's name is its result, which is assigned: Total = 1 inside Function Total() is not this.

See also


⏮️ VBC09354 Invalid qualifier | ⏭️ VBC09356 Wrong number of dimensions


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