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.
Copy Code | |
---|---|
myScript.vbs /c:"WSH is a wonderful thing" /s:"scripts are wonderful" |
Next, add the following VBScript code.
Copy Code | |
---|---|
For i = 0 to WScript.Arguments.Count-1 WScript.Echo WScript.Arguments.Named(i) next i |
Following is the result.
Copy Code | |
---|---|
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.
Copy Code | |
---|---|
myscript.vbs "WSH is a wonderful thing" "scripts are wonderful" |
Next, add the following VBScript code.
Copy Code | |
---|---|
For i = 0 to WScript.Arguments.Count-1 WScript.Echo WScript.Arguments.Unnamed(i) next i |
Following is the result.
Copy Code | |
---|---|
WSH is a wonderful thing scripts are wonderful |