VBC09314 — Exit Function not allowed in Sub or Property
Severity: Error · Family: VBC (static semantics / abstract syntax tree) ·
Source metadata: VBCompileErrorInfo
An Exit Function statement is in a Sub, or in a Property Let or a Property Set.
MS-VBAL §5.4.2.18 Exit Function Statement requires it to be inside the body of a function. MS-VBA reports the same error: Exit Function not allowed in Sub 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 Sub. |
Sub Foo() ... Exit Function |
Use Exit Sub. |
It is in a Property Let or a Property Set. |
Property Let Foo(ByVal v As Long) ... Exit Function |
Use Exit Property. |
Notes
An Exit Function in a Property Get is not reported. MS-VBAL §5.4.2.18 says it must be in a function, but MS-VBA accepts it in a property getter, and a
program written against MS-VBA relies on that.
See also
⏮️ VBC09313 Exit For not within For...Next | ⏭️ VBC09315 Exit Property not allowed in Sub or Function
ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca