|
|
Title | Use optional parameters with default values |
Keywords | optional, optional parameters, default |
Categories | Tips and Tricks, Software Engineering |
|
|
You cannot use IsMissing with this technique to see which arguments are missing. If you just want to use default values, however, this is easier and gives you stricter type checking than in available with Variants.
Use the Optional keyword before the parameter declaration and provide a default value after it. Optional parameters must come at the end of the parameter list. That means if one parameter is optional, all following parameters must also be optional.
|
|
Private Sub Draw(Optional X As Single = 720, Optional Y As _
Single = 2880)
Cls
Circle (X, Y), 700
End Sub
|
|
|
|
|
|