Try something like this:Sub SearchTextFileConst strFileName = 'C:MyFilesTextFile.txt'Const strSearch = 'Some Text'Dim strLine As StringDim f As IntegerDim lngLine As LongDim blnFound As Booleanf = FreeFileOpen strFileName For Input As #fDo While Not EOF(f)lngLine = lngLine + 1Line Input #f, strLineIf InStr(1, strLine, strSearch, vbBinar圜ompare) 0 ThenMsgBox 'Search string found in line ' & lngLine, vbInformationblnFound = TrueExit DoEnd IfLoopClose #fIf Not blnFound ThenMsgBox 'Search string not found', vbInformationEnd IfEnd SubRegards, Hans Vogelaar.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |