Results 1 to 4 of 4

Thread: how to open a txt file and search for a string

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Location
    Bergen, Norway
    Posts
    143

    Question

    Greetings,

    Here is a realy easy and stupid question

    I wonder how I can open a text file and then search it for a string and then display the info after string but only to the end of line.

    like this:

    FileInfo=File made by: blahblah blah..
    <html>
    <body background="/images/bground.gif" bgcolor="#ffffff" text="#000000" marginheight="0" topmargin="0">
    ...

    I want to be able to display the "File made by (and so on)"
    and also be able to not display the data on the next lines (the <html> and <body background="/images/bground.gif" bgcolor="#ffffff" text="#000000" marginheight="0" topmargin="0"> tags).

    Thanks in advance.


    -Lumin

  2. #2
    Guest


    Code:
    Option Explicit
    
    Dim FileNumber As Integer
    Dim TextLine As String
    
    
    Private Sub Command1_Click()
    
        FileNumber = FreeFile()
        
        Open "C:\Myfile.txt" For Input As FileNumber
            Do While Not EOF(FileNumber)
                'read line here
                Line Input #FileNumber, TextLine
                    'look for line of text that has "FileInfo=" in it
        If InStr(1, TextLine, "FileInfo=") <> 0 Then
                        List1.AddItem TextLine
                        List1.Refresh
                    End If
            Loop
        Close FileNumber

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Location
    Bergen, Norway
    Posts
    143
    Thanks.

    But how do I exclude the FileInfo= from the list?
    I only want to show the info that is coming after it.

    Anyway thanks a lot.


    -Lumin

  4. #4
    Guest
    this will eliminate FileInfo=


    Code:
    List1.AddItem Mid$(TextLine,10)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width