A
Arvi Laanemets
Hi
I have a function declared as:
----
Public Function EnchWorkdaysN(StartDate As Date, _
EndDate As Date, _
Optional Holidays As Variant = Nothing, _
Optional Weekends As Variant = Nothing)
....
End Function
----
How to check in code for optional parameters set to Nothing? When I used the
code
....
If Holidays Is Nothing Then
statement
Elseif ...
.....
then it works only, when I omit the parameter or when I leave it empty, i.e.
when the parameter is set to Nothing. But when the the optional parameter
has some value, the the VBA cancels at first test without any error message.
When I test in debug window p.e. for 'Holidays Is Nothing', then instead of
False, <Object required> is returned. And the same with 'Not(Holidays Is
Nothing)' too.
Thanks in advance
I have a function declared as:
----
Public Function EnchWorkdaysN(StartDate As Date, _
EndDate As Date, _
Optional Holidays As Variant = Nothing, _
Optional Weekends As Variant = Nothing)
....
End Function
----
How to check in code for optional parameters set to Nothing? When I used the
code
....
If Holidays Is Nothing Then
statement
Elseif ...
.....
then it works only, when I omit the parameter or when I leave it empty, i.e.
when the parameter is set to Nothing. But when the the optional parameter
has some value, the the VBA cancels at first test without any error message.
When I test in debug window p.e. for 'Holidays Is Nothing', then instead of
False, <Object required> is returned. And the same with 'Not(Holidays Is
Nothing)' too.
Thanks in advance