Search notes:

VBA - language: keyword isMissing

isMissing() is a VBA function to check if an optional parameter was given a value.
Unfortunately, it does not distinguish between passing null or not explicitly stating a value.
The data type of a parameter that needs to be checked with isMissing() needs to be a variant.
option explicit

sub main() ' {

  call xyz("one", "two")
  call xyz("apple")
  call xyz(param_2 := "banana")
  call xyz
  call xyz(param_2 :=  null)

  activeDocument.saved = true

 end sub  ' }


' xyz {
private sub xyz (                   _
       optional param_1 as variant, _
       optional param_2 as variant  _
)

     if isMissing(param_1) then
        selection.typeText("param_1 is missing")
     else
        selection.typeText("param_1 = " & param_1)
     end if

     if isMissing(param_2) then
        selection.typeText(" - param_2 is missing")
     else
        selection.typeText(" - param_2 = " & param_2)
     end if

     selection.typeText chr(13)

end sub  ' }
Github repository about-VBA, path: /language/subs-and-functions/optional-parameters/keyword-isMissing.bas

See also

VBA language

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758194759, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/VBA/language/subs-and-functions/optional-parameters/keyword-isMissing(85): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78