File Extension Filter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • igglepiggle
    New Member
    • Nov 2008
    • 2

    #1

    File Extension Filter

    I have developed a form that runs a folder browser dialog and then details all filenames within the chosen folder in a listbox. Currently the filenames populate a 1-D array before they are written out to the listbox.

    I need to introduce a combobox that will act as an extension filter. So, when the filenames are written to the listbox, the combobox is populated with the unique file extensions from this list. When the extension is clicked, only those files with that extension are shown in the listbox. <None> may be selected from the combo box to again show the full list of filenames.

    Advice would be appreciated on the best way to go about this, I see two possibilities, either to act upon the 1-D array as it stands, or introduce a 2-D array that does the stripping out of the extensions at the same time the filenames are written and then filter using these.

    Mank thanks
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Hey there good buddy!

    What version of VB do you need this in 6, or .NET?

    To be honest, I have no idea how this can be handled in VB6...

    Let us know!

    Comment

    • QVeen72
      Recognized Expert Top Contributor
      • Oct 2006
      • 1445

      #3
      Hi,

      Use a "FileListBo x" , It is a readymade control, set the path and Refresh, all the Files from the Said Path are populated..
      Add a ListBox, to show all the Extensions..
      Browse through all the available Files, and get Unique Extensions..
      Use another FileListBox, set The Pattern property, and refresh..
      Something Like This :

      [code=vb]
      File1.Path = "C:\MyFolde r"
      File1.Refresh

      File2.Path = "C:\MyFolde r"
      File2.Pattern = "*.txt"
      File2.Refresh
      [/code]

      Regards
      Veena

      Comment

      • smartchap
        New Member
        • Dec 2007
        • 236

        #4
        Solution given by QVeen is good. Add a combo box for selection of extensions and use its Click event to select an extension.

        Comment

        Working...