Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
This topic describes which Visual Basic types can be declared within which other types, and what their access levels default to if not specified.
The declaration context of a programming element is the region of code in which it is declared. This is often another programming element, which is then called the containing element.
The levels for declaration contexts are the following:
Namespace level — within a source file or namespace but not within a class, structure, module, or interface
Module level — within a class, structure, module, or interface but not within a procedure or block
Procedure level — within a procedure or block (such as If
or For
)
The following table shows the default access levels for various declared programming elements, depending on their declaration contexts.
Declared element | Namespace level | Module level | Procedure level |
---|---|---|---|
Variable (Dim Statement) | Not allowed | Private (Public in Structure , not allowed in Interface ) |
Public |
Constant (Const Statement) | Not allowed | Private (Public in Structure , not allowed in Interface ) |
Public |
Enumeration (Enum Statement) | Friend |
Public |
Not allowed |
Class (Class Statement) | Friend |
Public |
Not allowed |
Structure (Structure Statement) | Friend |
Public |
Not allowed |
Module (Module Statement) | Friend |
Not allowed | Not allowed |
Interface (Interface Statement) | Friend |
Public |
Not allowed |
Procedure (Function Statement, Sub Statement) | Not allowed | Public |
Not allowed |
External reference (Declare Statement) | Not allowed | Public (not allowed in Interface ) |
Not allowed |
Operator (Operator Statement) | Not allowed | Public (not allowed in Interface or Module ) |
Not allowed |
Property (Property Statement) | Not allowed | Public |
Not allowed |
Default property (Default) | Not allowed | Public (not allowed in Module ) |
Not allowed |
Event (Event Statement) | Not allowed | Public |
Not allowed |
Delegate (Delegate Statement) | Friend |
Public |
Not allowed |
For more information, see Access levels in Visual Basic.
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register now