Count Method (Windows Script Host)
Returns the number of members in an object.
object.Count
Arguments
- object
A WshArguments, WshEnvironment, WshNamed, WshSpecialFolders, or WshUnnamed object, or the WScriptArguments property.
Remarks
The Count method returns an integer value. The Count method is primarily intended for VBScript users. JScript users should generally use the length property instead.
Example (WshNamed)
The following example demonstrates the Count method using the WshNamed object. Begin by typing the following text at the Command Prompt.
myScript.vbs /c:"WSH is a wonderful thing" /s:"scripts are wonderful"
Next, add the following VBScript code.
For i = 0 to WScript.Arguments.Count-1
WScript.Echo WScript.Arguments.Named(i)
next i
Following is the result.
WSH is a wonderful thing
scripts are wonderful
Example (WshUnnamed)
The following example demonstrates the Count method using the WshUnnamed object. Begin by typing the following text at the command line.
myscript.vbs "WSH is a wonderful thing" "scripts are wonderful"
Next, add the following VBScript code.
For i = 0 to WScript.Arguments.Count-1
WScript.Echo WScript.Arguments.Unnamed(i)
next i
Following is the result.
WSH is a wonderful thing
scripts are wonderful
Applies To:
Arguments Property (WScript Object)| WshArguments Object| WshEnvironment Object| WshNamed Object| WshSpecialFolders Object| WshUnnamed Object
See Also
Reference
Item Property (WshNamed)
Exists Method (Windows Script Host)
Length Property