WSH » WshArguments » Item

object.Item (lngIndex)
Receives the index of a specific element to be returned.

The Item method is the default method of the WshArguments object. It references an array of strings containing the arguments. If lngIndex is specified, this method returns the element in the collection at the specified position. Indexing starts at zero. If there is no element at the requested index, a "Subscript out of range" error is generated.


WScript.Echo "The first argument is", WScript.Arguments(0)
WScript.Echo "The second argument is", WScript.Arguments.Item(1)
The first argument is abc
The second argument is def

This VBScript code displays the first and second arguments passed to the current script. The output shown would be observed if the script were invoked with two command-line arguments: "abc" and "def". The example also illustrates both forms of syntax that can be used to call the default Item method.

Language(s): VBScript