This example uses the IsMissing function to check if an optional argument has been passed to a user-defined procedure. Note that Optional arguments can now have default values and types other than Variant.
Dim ReturnValue
' The following statements call the user-defined function procedure.
ReturnValue = ReturnTwice() ' Returns Null.
ReturnValue = ReturnTwice(2) ' Returns 4.
' Function procedure definition.
Function ReturnTwice(Optional A)
If IsMissing(A) Then
' If argument is missing, return a Null.
ReturnTwice = Null
Else
' If argument is present, return twice the value.
ReturnTwice = A * 2
End If
End Function