Name
Class Statement
Syntax
[accessmodifier] [Shadows] [inheritability] Class Name
statements
End Class
-
accessmodifier
(optional; Keyword) The possible values of
accessmodifier
arePublic
,Private
, andFriend
. For more information, see Section 4.7 in Chapter 4.-
Shadows
(optional; Keyword) Indicates that the
Name
class shadows any element of this same name in a base class.-
inheritability
(optional; Keyword) One of the keywords,
MustInherit
orNotInheritable
, must be used.MustInherit
specifies that objects of this class cannot be created, but that objects of derived classes can be created.NotInheritable
specifies 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
Inherits
orImplements
statements appear in a class module, they must appear before any other statements in the module. Moreover, theInherits
keyword must appear before theImplements
keyword.Name
follows standard Visual Basic variable-naming conventions.Within a class code block, members are declared as
Public
,Private
,Protected
,Friend
, orProtected
Friend
. TheDim
keyword is equivalent toPrivate
when used in class modules (but it is equivalent toPublic
in structures). Property declarations are automaticallyPublic
.The
Class...End
Class
construct can include the following ...
Get VB.NET Language in a Nutshell, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.