Results 1 to 5 of 5

Thread: Searching in folders

  1. #1
    Guest

    Post

    How do you search within a folder for specific files? I've got browse functionality included to get to the folder I want.

    Cheers

  2. #2
    Hyperactive Member venkatraman_r's Avatar
    Join Date
    Jul 1999
    Location
    Chennai, INDIA
    Posts
    284

    Post

    Add this module, add a drive list box and a command button....

    Private Sub FindIt(sStartPath As String, sPattern As String)
    On Error GoTo VenError:
    Dim fso As FileSystemObject
    Dim fld As Folder
    Dim fldCurrent As Folder
    Dim sFile As String

    Screen.MousePointer = vbHourglass

    Set fso = New FileSystemObject
    If Right$(sStartPath, 1) <> "\" Then
    sStartPath = sStartPath & "\"
    End If

    Set fldCurrent = fso.GetFolder(sStartPath)
    sFile = Dir(sStartPath & sPattern, vbNormal)

    Do While Len(sFile) > 0
    List1.AddItem sStartPath & sFile
    sFile = Dir
    Loop
    end sub

    in the command button:

    Call FindIt(Drive1.Drive & "\", "*.mdb")

    Where u can specify the file type u need instead of "mdb".

    Hope this helps,

    Venkat.

  3. #3
    Guest

    Post

    Venkat

    Thanks for the code but I can't get it to work. An error came up with the call FindIt to say that it isn't defined, so I made in public, now I've got an error with the FileSystemObject and Folder saying that the user types aren't defined. What should I do.

    V

  4. #4
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    Venkatraman is using the File System Objects which requires the MS Scripting Runtime File(s).
    Goto Project.. References and put a Check in MS Scripting Runtime and it should recognize them.

    ------------------
    Aaron Young
    Analyst Programmer
    aarony@redwingsoftware.com
    ajyoung@pressenter.com


  5. #5
    Guest

    Post

    Thank You........Again!

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