Alternative to FOR EACH
From: J. van Heerde (Han_at_b-v-h.demon.nl)
Date: 04/16/04
- Next message: Richard Mueller [MVP]: "Re: CurrentUser.MemberOf"
- Previous message: Joe Bramlage: "error '80041010' using WMI SNMP in an ASP page."
- Next in thread: Viatcheslav V. Vassiliev: "Re: Alternative to FOR EACH"
- Reply: Viatcheslav V. Vassiliev: "Re: Alternative to FOR EACH"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 16 Apr 2004 17:19:57 GMT
Hi Scripting Guys,
I've been reading a lot of information on VBScript, WMI, WSH, but
can't find a solution to my problem.. I'm not only using all examples
for VBScript, but also for another programming language. In the
Windows 2000 Scripting Guide I came across the following example:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set colDrives = objFSO.Drives
For Each objDrive in colDrives
Wscript.Echo "Drive letter: " & objDrive.DriveLetter
Next
This works fine in VBScript.
I have one big problem. The programming language I use doesn't support
the FOR EACH .... IN .... command. With other examples I've always
managed to use the .Count property to set up a FOR ... TO .... command
in combination with the .Item() method. I've been digging the
Internet, but can't find any method for solving my problem.
How do I reference one specific object in the Drives collection in the
FileSystemObject by index number?
The following command does work, but is of no use, because it presumes
I already know the drive letter.
Wscript.Echo "Drive letter: " & objDrive.Item( "a:" ).DriveLetter
The following code simply doesn't work.....
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set colDrives = objFSO.Drives
For counter = 1 TO colDrives.Count
Wscript.Echo "Drive letter: " & colDrives.Item( counter ).DriveLetter
Next
I also tried using the dictionary object, but didn't know how to
transfer this collection to a dictionary collection.......(again by
NOT using the FOR EACH command).
Can anybody help?
Kind regards,
Han
- Next message: Richard Mueller [MVP]: "Re: CurrentUser.MemberOf"
- Previous message: Joe Bramlage: "error '80041010' using WMI SNMP in an ASP page."
- Next in thread: Viatcheslav V. Vassiliev: "Re: Alternative to FOR EACH"
- Reply: Viatcheslav V. Vassiliev: "Re: Alternative to FOR EACH"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|