Author Topic: IWshCollection.Item Method  (Read 3714 times)

0 Members and 1 Guest are viewing this topic.

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2512
  • User-Rate: +209/-0
IWshCollection.Item Method
« on: July 14, 2008, 10:53:33 PM »

The following code illustrates the use of the Item method:

Code: [Select]
#INCLUDE "WSHOM.INC"

DIM pWsh AS IWshShell
DIM pSpecialFolders AS IWshCollection
DIM nCount AS LONG
DIM i AS LONG
DIM vItem AS VARIANT
DIM vValue AS VARIANT

pWsh = NEWCOM "WScript.Shell"
' Get a reference to the special folders collection
pSpecialFolders = pWsh.SpecialFolders

' Get the number of objects in the collection
nCount = pSpecialFolders.Count

' Enumerates the collection
FOR i = 0 TO nCount - 1
   vItem = i AS LONG
   vValue = pSpecialFolders.Item(vItem)
   IF OBJRESULT THEN EXIT FOR
   STDOUT VARIANT$(vValue)
NEXT
« Last Edit: January 20, 2009, 12:58:34 AM by José Roca »