How does one write optional parameters in functions and sub.?
Printable View
How does one write optional parameters in functions and sub.?
Use the OPTIONAL keyword in the argument list, for example....
As with VB6, that if you make 1 argument optional, then all arguments that follow must also be optional.Code:Private Sub SomeSubRoutine(ByVal Par1 As String, Optional Par2 As Long = 0, Optional ByVal Par3 As Boolean = False)
And one change from VB6, is that you must always specify the default value for the optional argument.