Show Contents / Index / Search

Named Arguments

You can use named arguments to reorder arguments and omit optional arguments. Or, use them as a means of identifying the arguments in your commands.

Note: If you use the syntax shown in the Help topic for any Reflection method, you must put your arguments in the same order as they appear in the syntax line.

A named argument consists of a token (Token) to identify an argument, followed by a colon (:) and an equal sign (=), and then the argument value:

Token:= ArgumentValue

(In the syntax statement, the token name is the same as the argument name.)

Example

The SearchText1 method takes four arguments. Using standard syntax, the String argument must always be given first. The line continuation character, an underscore preceded by a space, is used to break up long lines of code.

Dim sp As ScreenPoint

Set sp = ThisIbmScreen.SearchText1("USERID", 8, 1, _ FindOption.FindOption_Forward)

 

Using tokens derived from the syntax line, you can modify this command to use named arguments:

Set sp = ThisIbmScreen.SearchText1(Text:="USERID",StartRow:=8, _
StartColumn:=1,FindOption:=FindOption.FindOption_Forward)

 

Using named arguments, you can reorder arguments, so that the following command is equivalent to the one above:

Set sp = ThisIbmScreen.SearchText1(FindOption:=FindOption.FindOption_Forward, _
StartRow:=8, StartColumn:=1, Text:="USERID")

 

For user-defined procedures, the token name is the variable name you use when you define the procedure.