Optional Keyword

Used in parameter declarations to indicate that a parameter is optional.

# Notes

Optional parameter

Part | Type | Description
--- | --- | ---
parameter | Any Data Type | Parameter that is optional.

When you use the Optional keyword in a parameter declaration, you make the parameter optional without specifying a default value The other way of specifying an optional parameter is to give it a default value in the declaration. If you omit the third parameter when you call such a method, the omitted parameter gets the default value you specified in the declaration.

The Optional keyword precedes the parameter name in the declaration. If the calling statement omits this parameter, it will receive the standard initial value for its type.

# Example

If the method declaration is:

myMethod (a as Integer, b as Integer, Optional c as Integer)

The call can omit the third parameter and the last parameter, c, will get the default value of 0.

The other way of making the parameter optional is to give it a default value in the declaration, such as:

myMethod (a as Integer, b as Integer, c as Integer = 10)