From: Ranah van Rijswijk on
I would like to list all filenames in a file collection without using
for each ... next but a for .. next loop instead.

Could someone help me?
Thanks in advance.

Ranah

-------
Set filesys = CreateObject("Scripting.FileSystemObject")
Set demofolder = filesys.GetFolder("c:\")
Set filecoll = demofolder.Files

for n = 0 to filecoll.count-1 step 2
msg = msg & filecoll.item(n).name & VbCrLf
next

msgbox msg
From: Paul Randall on
The VBScript documentation isn't very good on this subject. I typically
attempt to get a count or length property for things like this.
msgbox showfilelist("c:\")
Function ShowFileList(folderspec)
Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.Files
s = "file count = " & fc.count & vbcrlf
For Each f1 in fc
s = s & f1.name & vbcrlf
Next
ShowFileList = s
End Function

-Paul Randall

"Ranah van Rijswijk" <ranah.v.rijswijk(a)gmail.com> wrote in message
news:86aba9ec-af4c-4c36-98c6-f9e7fd0aefa0(a)u9g2000yqb.googlegroups.com...
>I would like to list all filenames in a file collection without using
> for each ... next but a for .. next loop instead.
>
> Could someone help me?
> Thanks in advance.
>
> Ranah
>
> -------
> Set filesys = CreateObject("Scripting.FileSystemObject")
> Set demofolder = filesys.GetFolder("c:\")
> Set filecoll = demofolder.Files
>
> for n = 0 to filecoll.count-1 step 2
> msg = msg & filecoll.item(n).name & VbCrLf
> next
>
> msgbox msg


From: Todd Vargo on
Ranah van Rijswijk wrote:
>I would like to list all filenames in a file collection without using
> for each ... next but a for .. next loop instead.
>
> Could someone help me?
> Thanks in advance.
>
> Ranah
>
> -------
> Set filesys = CreateObject("Scripting.FileSystemObject")
> Set demofolder = filesys.GetFolder("c:\")
> Set filecoll = demofolder.Files
>
> for n = 0 to filecoll.count-1 step 2
> msg = msg & filecoll.item(n).name & VbCrLf
> next
>
> msgbox msg

Why do you have the "step 2" in your loop?
Are you trying to skip files in your list?

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)