• List box contents

    Author
    Topic
    #356860

    Hi all,

    What would be the best way to populate the contents of a list box with the contents of a directory? I have looked at GetObject, Path, and Dir, but I am a little unsure which to start with.

    I would like to populate the list box with the directory contents, and then use the click event to open whichever file is clicked.

    Thanks,

    Viewing 0 reply threads
    Author
    Replies
    • #528979

      Mike,

      I think there have been several posts on how to loop through a directory and find the names of the files in it; e.g. This post might help you. But I think that Legare has posted a somewhat more easy macro to do more or less the same. Anyhow, once you have the names of the files of a particular directory in an array, you can easily fill the listbox with the elements of that array, using somewhat similar to:

      For i = 1 to Ubound(FileArray)
        ListBox1. AddItem FileArray(i)
      Next i
      
    Viewing 0 reply threads
    Reply To: List box contents

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: