Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Help with ASP Collection Object
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Help with ASP Collection Object

 Post Reply Post Reply
Author
tim_r View Drop Down
Newbie
Newbie


Joined: 05 January 2004
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote tim_r Quote  Post ReplyReply Direct Link To This Post Topic: Help with ASP Collection Object
    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

Back to Top
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post Posted: 09 February 2004 at 7:31pm
about the property... not sure
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.