Appendix D. Subroutine and Function Declarations

This appendix provides information about subroutine, function, and generic declarations. A property procedure includes a subroutine and function pair, so they are also described here.

SUBROUTINES

The syntax for writing a subroutine is as follows:

[attribute_list] [interitance_mode] [accessibility]
Sub subroutine_name [(parameters)] [ Implements interface.procedure ]
    [ statements ]
End Sub

The inheritance_mode can be one of the following values: Overloads, Overrides, Overridable, NotOverridable, MustOverride, Shadows, or Shared. These values determine how a subroutine declared within a class inherits from the parent class or how it allows inheritance in derived classes.

The accessibility clause can take one of the following values: Public, Protected, Friend, Protected Friend, or Private. These values determine which pieces of code can invoke the subroutine.

FUNCTIONS

The syntax for writing a function is as follows:

[attribute_list] [interitance_mode] [accessibility] _
Function function_name([parameters]) [As return_type] [ Implements interface.function ]
    [ statements ]
End Function

This is the same as the syntax used for declaring a subroutine, except that a function includes a return type and ends with End Function.

The inheritance_mode can be one of the values Overloads, Overrides, Overridable, NotOverridable, MustOverride, Shadows, or Shared. These values determine how a subroutine declared within a class inherits from the parent class or ...

Get Visual Basic® 2010 Programmer's Reference 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.