O'Reilly logo

Application Development Using Visual Basic® and .NET by Dana L. Wyatt, Peter Thorsteinson, Robert J. Oberg

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

Optional Parameters

VB.NET allows parameters to be defined as optional. That is, the calling statement may or may not pass a value for that parameter. If optional parameters are defined, a default value for them must be specified. When arguments are passed, the actual argument is used. When no argument is passed, the default value for the parameter is used.

To define a parameter as optional, the keyword Optional is used. The default value for the parameter is specified using the assignment operator and a value after the declaration. The example OptionalParameters illustrates the use of these parameters.

 ' Calculates shipping costs; assumes that the Rapid Express ' is the default shipper. Shipper codes are: ' 1=Rapid Express, 2=Quick Shippers, ...

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