Name

Sub Statement

Syntax

[ClassBehavior] [AccessModifier] Sub name [(arglist)] 
   [statements]
   [Exit Sub] 
   [statements]
End Sub
ClassBehavior

Use: Optional

Type: Keyword

One of the keywords shown in the following table:

Keyword

Description

Overloads

Indicates that more than one declaration of this subroutine exists (with different argument signatures).

Overrides

For derived classes, indicates that the subroutine overrides the subroutine by the same name (and argument signature) in the base class.

Overridable

Indicates that the subroutine can be overridden in a derived class.

NotOverridable

Indicates that the subroutine cannot be overridden in a derived class.

MustOverride

Indicates that the subroutine must be overridden in a derived class.

Shadows

In a derived class definition, indicates that calls to derived class members that are made through a base class ignore the shadowed implementation.

Shared

Callable without creating an object of the class. It is, in this strange sense, shared by all objects of the class. These are also called static subroutines .

AccessModifier

Use: Optional

The possible values of AccessModifier are Public, Private, Friend, Protected, or Protected Friend. The following table describes the effects of the various access modifiers. Note that “direct access” refers to accessing the member without any qualification, as in:

classvariable = 100

and “class/object access” refers to accessing the member through qualification, either ...

Get VB .NET Language in a Nutshell 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.