Solved

Retreiving a list of files from a directory

Posted on 2002-06-24
2
170 Views
Last Modified: 2010-05-02
I want to browse a certain directory on a hard drive for a certain file type.
I can do this with the FileListBox (using the Pattern and Path properties) but I want to change the display so the file extension isn't shown.
What I could really do with is an API call that returns a list or windows handles to the files in the directory.

Any ideas?

Thanks,
Andy.
 
0
Comment
Question by:HelpAndy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 100 total points
ID: 7103425
Use a listbox and the Dir() function:

Private Sub PopFiles(ByVal Pattern As String, ByVal SourcePath As String, ByRef LBox As ListBox)
  Dim strFileName As String
  LBox.Clear
  strFileName = Dir(SourcePath & "\" & Pattern)
  Do While strFileName <> ""
    LBox.AddItem Left(strFileName,Instr(strFilename,".") - 1)
    strFileName = Dir()
  Loop
End Sub

Then call like:

PopFiles "*.txt","c:\Myfolder",List1

To get a list box filled with the filenames minus the extension.
0
 

Author Comment

by:HelpAndy
ID: 7103450
You beauty, thanks Tim.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question