Declaration Contexts and Default Access Levels
This article tells which declared elements you can use in other declared elements, and their access levels.
Declaration contexts
The declaration context of a programming element is the part of the code in which it is declared. Frequently this is a different programming element, which is also known as the container element.
The levels of declaration contexts follow:
- Namespace level – in a namespace (but not in a module, class, structure, or trait)
- Module level – in a module, class, structure, or trait (but not in a procedure or block)
- Procedure level – in a procedure or block
(for example,
If
orWhile
)
Access levels
The table that follows shows the default access levels for many declared elements, given their declaration contexts.
Declared element | Statements | Namespace level | Module level | Procedure level |
---|---|---|---|---|
Variable | Dim /Var ,
New ,
Object |
Not permitted | TBD | TBD |
Constant | Const |
Not permitted | TBD | TBD |
Enumeration | Enum |
TBD | TBD | TBD |
Class | Class |
TBD | TBD | TBD |
Structure | Struct |
TBD | TBD | TBD |
Trait | Trait |
TBD | TBD | TBD |
Method | Method |
TBD | TBD | TBD |
Property | Property |
TBD | TBD | TBD |
Declare | Declare |
TBD | TBD | TBD |
Function | Function |
TBD | TBD | TBD |
Sub | Sub |
TBD | TBD | TBD |
Event | Event |
TBD | TBD | TBD |