IsMissing (function)

Syntax IsMissing (variable)
Description Returns True if variable was passed to the current subroutine or function; returns False if omitted.
Comments The IsMissing is used with variant variables passed as optional parameters (using the Optional keyword) to the current subroutine or function. For non-variant variables or variables that were not declared with the Optional keyword, IsMissing will always return True .
Example The following function runs an application and optionally minimizes it. If the optional isMinimize parameter is not specified by the caller, then the application is not minimized.
Sub Test(AppName As String,Optional isMinimize As Variant)
????app = Shell(AppName)
????If Not IsMissing(isMinimize) Then
????????AppMinimize app
????Else
????????AppMaximize app
????End If
End Sub
Sub Main
????Test "notepad.exe"????????????????????'Maximize this application
????Test "notepad.exe",True??????????'Minimize this application
End Sub
See Also Declare (statement), Sub...End Sub (statement), Function...End Function (statement)