How to filter FileListbox for wildcard

Discussion in 'AutoCAD' started by Mark Propst, Jul 25, 2003.

  1. Mark Propst

    Mark Propst Guest

    Hi.
    I have a form with drivelistbox dirlistbox and filelistbox
    this sub fills the filelistbox when the dirlist is changed

    Private Sub DirSourceFldr_Change()
    ' When directory changes, set file path.
    'Dim strfilename As String
    'Debug.Print strfilename

    'this line fills the filelistbox with all the files
    lstSourceFiles.Path = DirSourceFldr.Path
    'is there a way to filter what is displayed?
    'or do I need to step through with something like:
    Dim i As Long
    For i = 0 To lstSourceFiles.ListCount
    If Not lstSourceFiles.List(i) Like txtSearchFilter Then
    '....didn't find removeitem method
    Debug.Print lstSourceFiles.List(i)
    Debug.Print txtSearchFilter
    Debug.Print "not a match"
    Else
    Debug.Print lstSourceFiles.List(i)
    Debug.Print txtSearchFilter
    Debug.Print "match"

    End If
    i = i + 1

    Next
    End Sub

    'or do I need to make the filelistbox invisible and make a listbox visible
    then sort through the file list as above and fill the listbox with .AddItem
    if the name passes the wildcard test???
    or is there some other way to do this.
    If I only needed one fileselection box I could use a commonDialog or a
    showopen class api but this form has two path comparison display a source
    path and a compare path side by side so I don't know how I'd do that with a
    common dialog, which would be filterable with one of its flags or something
    (i think)
    any ideas?
    Mark
     
    Mark Propst, Jul 25, 2003
    #1
  2. Mark Propst

    Mark Propst Guest

    Found it!
    FileListbox. Pattern = matchcriteria
    Don't know why I didn't see that before.
     
    Mark Propst, Jul 25, 2003
    #2
  3. It's been soooo long since I used those controls, Mark, that I can'
    remember off the top of my head where the filter is at but I do know
    there is one. So why am I replying? You should check out VBNet
    [http://www.mvps.org/vbnet/index.html] and try using the api instead of
    the controls - its faster and easier than using the antiquated
    drive/folder/file controls. Just an alternative idea ;)
    ___________________________
    Mike Tuersley
    AutoCAD Clinic
    Rand IMAGINiT Technologies
     
    Mike Tuersley, Jul 25, 2003
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.