7.18. Optional Parameters

Methods can have optional parameters. Declaring a parameter as optional allows the calling method to vary the number of arguments to pass. Optional parameters specify a default value that is assigned to the parameter if the optional argument is not passed. Overloaded methods are generally more flexible than methods with optional parameters. For instance, you can specify different return types for overloaded methods.

You can create methods with one or more optional parameters. All optional parameters, however, must be placed to the right of the method’s non-optional parameters.

Common Programming Error 7.10

Declaring a ...

Get Visual Basic 2005 for Programmers: Deitel Developer Series, 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.