Table of Contents

RDC00216: Function result discarded

Severity: Hint  ·  Family: RDC (Rubberduck Core analyzers)  ·  Raised by: FunctionReturnValueDiscardedAnalyzer

A Function of the project is called as a statement, so the value it returns is not used.

A call statement can call a Function as well as a Sub (MS-VBAL §5.4.2.1 Call Statement). The function runs, and what it returns is discarded. That is sometimes intended, when the function is called for what it does. Often the value was meant to be used: a result to check, or an error code to handle.

The functions of a library (MsgBox) are not reported, nor is a call that is bound only when the code runs, such as a method called on an Object variable.

The finding is the name of the function, where it is called.

How it is raised

Situation Example Resolution
A function of the project called as a statement. Save path, where Save is a Function that returns False when it fails Use the value (If Not Save(path) Then ...), or make it a Sub if no caller needs it.
The same, with Call. Call Save(path) Same.

See also


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