M
mickey
Have run across a problem with an optional variant.
Code Example:
Function X (A As Range, Optional B As Variant = ?) As Variant
If IsEmpty(B) Then MsgBox "B is Empty"
If IsNull(B) Then MsgBox "B is Null"
If IsError(B) Then MsgBox "B is Error"
If the optional argument "B" is initialized to "Null" (i.e. Optional B As
Variant = Null) then the message "B is Null" is displayed. However, if "B"
is initialized to "Empty" (i.e. Optional B As Variant = Empty), the "IsEmpty"
is false and the message "B is Error" is displayed.
Does anyone know why the initialization of "B" to "Empty" results in an error?
Thanks.
Code Example:
Function X (A As Range, Optional B As Variant = ?) As Variant
If IsEmpty(B) Then MsgBox "B is Empty"
If IsNull(B) Then MsgBox "B is Null"
If IsError(B) Then MsgBox "B is Error"
If the optional argument "B" is initialized to "Null" (i.e. Optional B As
Variant = Null) then the message "B is Null" is displayed. However, if "B"
is initialized to "Empty" (i.e. Optional B As Variant = Empty), the "IsEmpty"
is false and the message "B is Error" is displayed.
Does anyone know why the initialization of "B" to "Empty" results in an error?
Thanks.