|
-
Jan 9th, 2009, 04:20 PM
#2
Member
Re: VB6 Search Box to search for text inside multiple word documents
Here ya go buddy add a command button, textbox named txtDirectory and a listbox , in the textbox put the directory eg: C:\folder or whatever and where it says find what you can add another textbox an use a variable course you'd have to modify it a little to work as you need it but anyone else has suggestions should post em
Private Sub Command1_Click()
dir_name = txtDirectory.Text
If Right$(dir_name, 1) <> "\" Then dir_name = dir_name _
& "\"
file_name = Dir$(dir_name & "*.*")
Do While Len(file_name) > 0
pos = InStrRev(file_name, ".")
If pos = 0 Then
ext = ""
Else
ext = LCase$(Mid$(file_name, pos))
End If
Select Case ext
'include file extensions add your own
Case ".txt", ".rtf", ".doc"
Dim sSearch As String
Dim sName As String
Open dir_name & "\" & file_name For Input As #1
sSearch = Input(LOF(1), #1)
Close #1
sName = InStr(1, sSearch, "FINDWHAT")
If sName > 0 Then
List1.AddItem file_name
Else
Exit Sub
End If
End Select
GetNextFile:
file_name = Dir$()
Loop
End Sub
Last edited by Evilribbet; Jan 9th, 2009 at 04:24 PM.
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
|