Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'SAW EXTRACT BUTTON
ofd3.ShowDialog()
If Not Me.txtFile.Text = "close" Then
Dim instance As COMException
' Set this to the file to search
strInputFile = Me.txtFile.Text
' Set this to the new file to create
strOutputFile = (ofd3.FileName)
' Set the specific text to search for
strTextToFind = "C"
Texttofind = "FB"
' Set this to determine whether to match with case sensitivity
boolMatchCaseSensitive = False
objFSO = CreateObject("Scripting.FileSystemObject")
Const intForReading = 1
Const intForWriting = 2
Const intForAppending = 8
objInputFile = objFSO.OpenTextFile(strInputFile, intForReading, False)
strFoundText = ""
' Read the first line if the file is not empty
While Not objInputFile.AtEndOfStream
strLine = objInputFile.Readline
If boolMatchCaseSensitive = False Then
If InStr(LCase(strLine), LCase(strTextToFind)) > 0 Then strFoundText = strLine
Else
If InStr(strLine, strTextToFind) > 0 Then strFoundText = strLine
End If
End While
objInputFile.Close()
objInputFile = Nothing
If strFoundText <> "" Then
objOutputFile = objFSO.OpenTextFile(strOutputFile, intForAppending, True)
objOutputFile.WriteLine(strFoundText)
objOutputFile.Close()
objOutputFile = Nothing
objFSO = Nothing
MsgBox(" Added To Saw Cut Sheet")
Else
MsgBox(strTextToFind & vbCrLf & "was not found in" & strInputFile)
End If
'SAW EXTRACT BUTTON
ofd3.ShowDialog()
If Not Me.txtFile.Text = "close" Then
Dim instance As COMException
' Set this to the file to search
strInputFile = Me.txtFile.Text
' Set this to the new file to create
strOutputFile = (ofd3.FileName)
' Set the specific text to search for
strTextToFind = "C"
Texttofind = "FB"
' Set this to determine whether to match with case sensitivity
boolMatchCaseSensitive = False
objFSO = CreateObject("Scripting.FileSystemObject")
Const intForReading = 1
Const intForWriting = 2
Const intForAppending = 8
objInputFile = objFSO.OpenTextFile(strInputFile, intForReading, False)
strFoundText = ""
' Read the first line if the file is not empty
While Not objInputFile.AtEndOfStream
strLine = objInputFile.Readline
If boolMatchCaseSensitive = False Then
If InStr(LCase(strLine), LCase(strTextToFind)) > 0 Then strFoundText = strLine
Else
If InStr(strLine, strTextToFind) > 0 Then strFoundText = strLine
End If
End While
objInputFile.Close()
objInputFile = Nothing
If strFoundText <> "" Then
objOutputFile = objFSO.OpenTextFile(strOutputFile, intForAppending, True)
objOutputFile.WriteLine(strFoundText)
objOutputFile.Close()
objOutputFile = Nothing
objFSO = Nothing
MsgBox(" Added To Saw Cut Sheet")
Else
MsgBox(strTextToFind & vbCrLf & "was not found in" & strInputFile)
End If