Print Page | Close Window

Help with ASP Collection Object

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=9637
Printed Date: 31 March 2026 at 9:41pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Help with ASP Collection Object
Posted By: tim_r
Subject: Help with ASP Collection Object
Date Posted: 08 February 2004 at 10:54am

Hi

I'm new to ASP, so this is a simple problem...

The following code lists the sub folder names in a specified directory.  Rather than loop through the list I want to just pull out the n-th name in the collection.  How do I do this please?  Also is there a property that tells me how big the sub folders collection is?

Set fso = server.CreateObject("Scripting.FileSystemObject")
Set fo = fso.GetFolder(server.mapPath("/images/banner"))

Set fc = fo.SubFolders
For Each f in fc
    Response.Write(f.name & "<br/>")
Next

Cheers




Replies:
Posted By: pmormr
Date Posted: 09 February 2004 at 7:31pm

Set fso = server.CreateObject("Scripting.FileSystemObject")
Set fo = fso.GetFolder(server.mapPath("/images/banner"))
Set fc = fo.SubFolders

'create a variable n- hence the nth item in the collection
Dim n
n = 5 '5th item in collection

For Each f in fc
     If n=0 then
          Response.Write(f.name & "<br>")
     End If
     n = n - 1
Next

this should work for your purpose



-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: pmormr
Date Posted: 09 February 2004 at 7:31pm
about the property... not sure

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net