Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find string in textstream

Status
Not open for further replies.

wmbb

Technical User
Jul 17, 2005
320
NL
I'm using the folowing code

Code:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' References:
'' MS DAO 3.6
'' MS Scripting Runtime
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub ReadTxtImport()
On Error GoTo Err_ReadTxtImport

Dim fs As FileSystemObject, fd As Folder, fc As Files, f As File, ts As TextStream '' Variables for FileSystemObject
'Dim rst As DAO.Recordset
Dim strFolder As String, strFile As String
Dim strLine As String, strLineReturn As String
Dim strMagnification As String, strHighTension As String

strFolder = "C:\TextFiles\"

Set fs = CreateObject("Scripting.FileSystemObject")
Set fd = fs.GetFolder(strFolder)
Set fc = fd.Files

    For Each f In fc

        Set ts = f.OpenAsTextStream(1, -2)
        'Set rst = CurrentDb.OpenRecordset("tblTextFiles")
        
            Do While ts.AtEndOfStream <> True
                strFile = f.Name
                strLine = ts.ReadLine
                strLineReturn = Mid(strLine, InStr(strLine, "=") + 1)

                        If .....
                        End If
                

           Loop
    Next


ts.Close
rst.Close

Set rst = Nothing
Set ts = Nothing
Set fc = Nothing
Set fd = Nothing
Set fs = Nothing

Exit Sub

End Sub

I want a to look if the string "system on" is present in the textstream ts.
Subsequently the variable "answer" has to be set to "Yes" or "No"

Is this possible with a find funktion or does someone have a better idee.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top