Table of Contents

VBC09332 — Exit Sub not allowed in Function or Property

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

An Exit Sub statement is in a Function or a property.

MS-VBAL §5.4.2.17 Exit Sub Statement requires it to be inside the body of a subroutine. MS-VBA reports the same error: Exit Sub not allowed in Function or Property.

This code is raised by ExitStatementStaticSemantics, which StatementStaticSemanticsEvaluator and instruction-list lowering (InstructionListLowering) both ask, when they are told the kind of procedure the statement is in.

How it is raised

Situation Example Resolution
It is in a Function. Function Foo() ... Exit Sub Use Exit Function.
It is in a Property Get, Property Let or Property Set. Property Get Foo() ... Exit Sub Use Exit Property.

See also


⏮️ VBC09331 Sub or Function not defined | ⏭️ VBC09333 Variable required


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