Writing Procedures

Basic procedure declarations haven't changed dramatically between VB6 and Visual Basic .NET. Procedures that do not have a return value are still defined with the keyword Sub and procedures that return a value are still defined with the keyword Function.

You will notice a few subtle changes when implementing and using subroutines and functions. The first such change is the use of parentheses for calling subroutines and functions. Always use parentheses when calling a function or a subroutine, but you don't need to add the Call keyword. We will cover additional changes to procedures in the subsections that follow.

Writing Subroutines

A subroutine is defined by typing the keyword Sub followed by a name and parentheses. The bounds ...

Get Visual Basic® .NET Unleashed 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.