I am using the code below that was posted by killer42 in order to search for words in a textfile. I added the LCase$ to (S) and (TheString) so case would be ignored. I was wondering if the code could, just as easily, be adapted to accept a wildcard (*) at the beginning or end of the string to search for; in other words to be able to look for "*djust " and get "adjust" and look for "adjust*" and get "adjustment " as one answer. Any help would be appreciated.
Code:
[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 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) Then StringExistsInFile = True End If End Function
Comment