PDA

Click to See Complete Forum and Search --> : get list of files in the same directory


Insane Killa
Jan 12th, 2000, 08:35 PM
how do you get your program to get a list of files with a certain extension that are located in the same directory as your app into a listbox?

Mark Sreeves
Jan 12th, 2000, 08:59 PM
use a filelistbox
and ...

File1.Pattern = "*.exe" ' or whatever
File1.Path = App.Path
File1.Refresh

Joacim Andersson
Jan 12th, 2000, 09:06 PM
You can use the FileListBox. Just set the pattern property to whatever files you want to show.

If you want to use an ordinary ListBox you can use code simular to this:

Private Sub FillListBox(sPath$, sPattern$, lstBox As ListBox)
Dim sFile$
sPath = spath & IIf(Right$(sPath, 1)<>"\", "\", "")
sFile = Dir(sPath & sPattern)
Do While Len(sFile) > 0
lstBox.AddItem sFile
sFile = Dir
Loop
End Sub

You call the sub above in the following manner:
FillListBox "C:\", "*.exe", List1
This will fill a listbox named List1 whit all files in the C:\ directory that has the .Exe extension.

Good luck!

------------------
Joacim Andersson
joacim@programmer.net
joacim@yellowblazer.com
www.YellowBlazer.com (http://www.YellowBlazer.com)