VBC09338 — Cannot define a Public user-defined type within an object module
Severity: Error · Family: VBC (static semantics / abstract syntax tree) ·
Source metadata: VBCompileErrorInfo
A class module declares a user-defined type that is public: a Public Type, or a Type declared with no modifier, which is public.
A user-defined type of a class module is private to it. The class names it from within, by its name or through the name of the class (Dim t As Shapes.TState); another module cannot name it at all. A type that other modules use is declared in a standard module. An Enum of a class module may be public.
MS-VBA reports the same error: Cannot define a Public user-defined type within an object module.
This code is raised by PublicMemberSemantics, at the type.
How it is raised
| Situation | Example | Resolution |
|---|---|---|
A Public Type in a class module. |
Public Type TState … End Type |
Declare it Private, or move it to a standard module. |
A Type with no modifier in a class module. |
Type TState … End Type |
The same. |
See also
- RD-VBAL §2.6.2 Semantic Compilation Errors
- VBC09337 Not allowed as a Public member of an object module
⏮️ VBC09337 Not allowed as a Public member of an object module | ⏭️ VBC09339 Argument not optional
ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca