[RESOLVED] Loading wav file names to listbox
Hi there, I have a listbox called storedfilenames. What I would like to do is that in the folder where my project is, is that on the form load event I would like all of the wav files to have their filenames (not their pathways and filenames), loadeed into the listbox. I would like just the wav files loaded. Can anyone help? thanks!
Re: Loading wav file names to listbox
Use Dir() looking for .wav extension and couple that with InstrRev() looking for the last backslash to isolate the file name by itself. Do you need code?
Re: Loading wav file names to listbox
Re: Loading wav file names to listbox
You can do it without InStrRev(). Build a form with a command button and a list box. Then apply this code:
Code:
Private Sub Command1_Click()
Dim NameFile As String, SubDir As String
SubDir = CurDir$ & "\*.wav*" ' Change CurDir to whatever directory is being searched
NameFile = Dir$(SubDir)
Do While NameFile <> vbNullString
List1.AddItem NameFile
NameFile = Dir$
Loop
End Sub
Re: Loading wav file names to listbox