VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Find File

Code Man  (1 Submission)   Files/File Controls/Input/Output   Visual Basic 3.0   Unknown Difficulty   Wed 3rd February 2021

Will locate a file on any type of drive. I use it for lots of things with little modification. Very useful for looping through all your drives, folders, sub-folders, etc. Perfect for finding files, folders, types of drives, etc. Should be "readable" enough for newbies and ideal for experts as well. Uses File System Object (FSO). Works with VB 5 as long as you've installed VB Scripting support. Can be implemented in ASP's with very little effort.

Inputs
'name of the file you're looking for 'Form code... Private Sub cmdFindFile_Click() Dim strFileName As String Dim strTmp As String strFileName = InputBox("Enter file name to look for", "Find a file") If Len(strFileName) = 0 Then 'Hit cancel or didn't enter anything Else With cmdFindFile strTmp = .Caption .Caption = "Searching..." .Enabled = False FindIt (strFileName) .Caption = strTmp .Enabled = True End With End If End Sub

Assumes
'Paste code into a module or form 'If packaging, you'll need to ship scrrun.dll

Returns
'MsgBox containing path name

Side Effects
'If you have mapped network drives and don't have permissions to the 'root folders of those drives, you'll get an error. Easily fixable by not looking at those drives or placing more dynamic error handling code in there.

API Declarations
'None
'Set a Reference to MS Scripting Runtime

Rate Find File (3(3 Vote))
Find File.bas

Find File Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters