IsMissing Function
Description
Returns a Boolean value indicating whether an optional Variant argument has been passed to a procedure.
Syntax
IsMissing(argname)
The required argname argument contains the name of an optional Variant procedure argument.
Remarks
Use the IsMissing function to detect whether or not optional Variant arguments have been provided in calling a procedure. IsMissing returns True if no value has been passed for the specified argument; otherwise, it returns False. If IsMissing returns True for an argument, use of the missing argument in other code may cause a user-defined error. If IsMissing is used on a ParamArray argument, it always returns False. To detect an empty ParamArray, test to see if the array's upper bound is less than its lower bound.
See Also
Function statement, IsArray function, IsDate function, IsEmpty function, IsError function, IsNull function, IsNumeric function, IsObject function, Property Get statement, Property Let statement, Property Set statement, Sub statement, TypeName function, Variant data type, VarType function.
Example
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