grizzlyjdw2
Registered User.
- Local time
- Today, 04:58
- Joined
- Feb 26, 2009
- Messages
- 22
ok, here is my code to search the text file itself
Public Function StringExistsInFile(ByVal TheString As String, ByVal TheFile As String) As Boolean
Dim L As Long, S As String, FileNum As Integer
FileNum = FreeFile
'MsgBox TheString
'MsgBox TheFile
Open TheFile For Binary Access Read Shared As #FileNum
L = LOF(FileNum)
S = Space$(L)
Get #1, , S
Close #FileNum
If InStr(1, S, TheString, vbBinaryCompare) Then
StringExistsInFile = True
End If
'MsgBox StringExistsInFile
End Function
works great and is fast, but just one small problem. is there anyway to search the file for whole words only? for example if i have the word "network" and search for "work", it returns a true. thanks ahead of time
Public Function StringExistsInFile(ByVal TheString As String, ByVal TheFile As String) As Boolean
Dim L As Long, S As String, FileNum As Integer
FileNum = FreeFile
'MsgBox TheString
'MsgBox TheFile
Open TheFile For Binary Access Read Shared As #FileNum
L = LOF(FileNum)
S = Space$(L)
Get #1, , S
Close #FileNum
If InStr(1, S, TheString, vbBinaryCompare) Then
StringExistsInFile = True
End If
'MsgBox StringExistsInFile
End Function
works great and is fast, but just one small problem. is there anyway to search the file for whole words only? for example if i have the word "network" and search for "work", it returns a true. thanks ahead of time
