O'Reilly logo

Visual Basic 2012 Programmer's Reference by Rod Stephens

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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] [inheritance_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] [inheritance_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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required