Name
Class Statement
Syntax
[accessmodifier] [Shadows] [inheritability] Class NamestatementsEnd Class
-
accessmodifier(optional; Keyword) The possible values of
accessmodifierarePublic,Private, andFriend. For more information, see Section 4.7 in Chapter 4.-
Shadows(optional; Keyword) Indicates that the
Nameclass shadows any element of this same name in a base class.-
inheritability(optional; Keyword) One of the keywords,
MustInheritorNotInheritable, must be used.MustInheritspecifies that objects of this class cannot be created, but that objects of derived classes can be created.NotInheritablespecifies that this class cannot be used as a base class.-
Name(required; String literal) The name of the class.
Description
Defines a class and delimits the statements that define that class’ variables, properties, and methods. For a detailed discussion with examples, see Chapter 4.
Rules at a Glance
If the
InheritsorImplementsstatements appear in a class module, they must appear before any other statements in the module. Moreover, theInheritskeyword must appear before theImplementskeyword.Namefollows standard Visual Basic variable-naming conventions.Within a class code block, members are declared as
Public,Private,Protected,Friend, orProtectedFriend. TheDimkeyword is equivalent toPrivatewhen used in class modules (but it is equivalent toPublicin structures). Property declarations are automaticallyPublic.The
Class...EndClassconstruct can include the following ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access