also to find a string in a file:
VB Code:
Option Explicit Private Sub FindInFile(strFilePath As String, strString As String) Dim strFile As String Dim lngPos As Long Open strFilePath For Binary As #1 strFile = Input(LOF(1), #1) Close #1 lngPos = InStr(strFile, strString) If lngPos > 0 Then MsgBox "'" & strString & "' found in file: " & strFilePath & " at character position " & lngPos Else MsgBox "'" & strString & "' not found in file: " & strFilePath End If End Sub Private Sub Form_Load() FindInFile "C:\test.txt", "bob" End Sub
![]()




Reply With Quote