Quick References
ADO
ASP
CSS2
HTML
JavaScript
Jet SQL
VBScript
WML
WMLScript
WSH
XHTML
XML DOM
XSLT
Features
Knowledge Base
Tutorials
Partners
ZVON.ORG
XML
Planet Source Code
VisualBuilder
Web Design
Your HTML Source
XML/XSLT Forums
ASPAlliance
Scripts
Programmers Heaven
Tek-Tips Forums
Developer Fusion
Code Project
WshCollection Object
Method: WshCollection.Item
object[.
Item]
(varIndex)
The
Item
method is the default method of the
WshCollection
object. It takes a single argument which, although of type Variant, only returns useful results when it is a Long. When passed an argument of type Long, 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.
The following 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.
Code:
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set clDrives = WshNetwork.EnumNetworkDrives()
For intI=0 To clDrives.Count - 1 Step 2
WScript.Echo "Letter", clDrives(intI)
WScript.Echo "maps to drive", clDrives.Item(intI+1)
Next
Output:
Letter P:
maps to drive \\FileServer\public
Letter Q:
maps to drive \\FileServer\upload
Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information