PDA

Click to See Complete Forum and Search --> : File


HeSaidJoe
Dec 8th, 1999, 09:51 PM
I would like to list the filenames of all files in "C:\My Documents"
How do I do this?

I can count them with this but I need to list their names.'count files in a directory

Dim iFiles As Integer
Dim sDir As String
sDir = Dir("C:\My Documents\*.*", vbNormal)
While sDir <> ""
iFiles = iFiles + 1
sDir = Dir
Wend

MartinLiss
Dec 8th, 1999, 10:08 PM
Add something like MsgBox "The name of file number " & iFiles & " is " & sDir after the iFiles = iFiles + 1 line.


------------------
Marty

funkheads
Dec 9th, 1999, 04:00 AM
i think you would do something like this...

Dim iFiles As Integer
Dim sDir As String
sDir = Dir("C:\My Documents\*.*", vbNormal)
While sDir <> ""
'if youwant to keep count...
iFiles = iFiles + 1
'to add them to a listbox
List1.Additem sDir
sDir = Dir
Wend

--michael

KenX
Dec 9th, 1999, 12:35 PM
why don't you use the file control "FileListBox"?

e.g.
File1.Path = "C:\My Documents"

HeSaidJoe
Dec 9th, 1999, 06:21 PM
Thank you all..

I have it.