VBC09331 — Sub or Function not defined
Severity: Error · Family: VBC (static semantics / abstract syntax tree) ·
Source metadata: VBCompileErrorInfo
The code uses a statement, or calls a procedure, that the language it is written in does not have.
MS-VBA reports the same error for a call of a name that nothing declares:
Sub or Function not defined.
Which statements exist at all is the language's to say (SupportedLanguage), and the
platform's languages do not all have the same ones.
This code is raised by instruction-list lowering
(InstructionListLowering), which is told the language the body is
written in (InstructionLoweringOptions.Language). A body lowered for no language is lowered as written. The verbose detail names the statement.
How it is raised
| Situation | Example | Resolution |
|---|---|---|
A Print with no file number, in a language that does not have such a statement. |
Print "x", in RD-VBA or VB6 |
Print to a file number (Print #1, "x") or to the Immediate window (Debug.Print "x"). A bare Print is a statement of the platform's BASIC. |
Notes
In VB6 a bare Print is the Print member of the form or report it is written in. The platform has no forms yet, so it is not a statement of VB6 either.
In VBA Print is a reserved identifier: it is illegal as the name of anything, it has no semantics, and it is not a recognized statement inside a procedure. Only
the Immediate window accepts a bare Print, as it does Debug.Print, and the Immediate window is not procedure scope.
See also
⏮️ VBC09330 Invalid implemented member | ⏭️ VBC09332 Exit Sub not allowed in Function or Property
ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca