Results 1 to 5 of 5

Thread: [RESOLVED] Loading wav file names to listbox

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Resolved [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!

  2. #2
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    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?
    Doctor Ed

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Loading wav file names to listbox

    code would be awesome!!

  4. #4
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    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
    Doctor Ed

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Loading wav file names to listbox

    Fantastic thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width