|
-
Jan 4th, 2000, 06:28 PM
#1
How do you search within a folder for specific files? I've got browse functionality included to get to the folder I want.
Cheers
-
Jan 4th, 2000, 07:23 PM
#2
Hyperactive Member
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.
-
Jan 4th, 2000, 11:49 PM
#3
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
-
Jan 5th, 2000, 12:42 PM
#4
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
[email protected]
[email protected]
-
Jan 5th, 2000, 12:55 PM
#5
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|