Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading folder Contents to an array 1

Status
Not open for further replies.

sahmiele

Technical User
Sep 9, 2003
67
US
I would like to load a folder's file names into an array. The number of files in the folder are variable. The folder pathname is S:\L01. The arrayname is "fileloader". Thanks in advance!
 
Have a look at the Dir function and the ReDim Preserve instruction.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I can't seem to figure out how to use the Dir function. I see that it is the function I want, but the help page isn't very descriptive.
 
A starting point:
Dim strPathname As String
Dim fileloader()
Dim i As Long
Dim strFile As String
strPathname = "S:\L01"
strFile = Dir(strPathname & "\*.*")
While strFile <> ""
ReDim Preserve fileloader(i)
fileloader(i) = strFile
i = i + 1
strFile = Dir
Wend
MsBox (1 + UBound(fileloader)) & " files loaded in fileloader"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top