Results 1 to 3 of 3

Thread: [2008] - pulling data from text file code help

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2007
    Posts
    18

    [2008] - pulling data from text file code help

    I have a large text file and I'm trying to pull data from it. "SummaryList" is common to all the files and is the text line just above the data I need.

    The data I need to pull looks like this, with spaces between them...
    0 188 22 33 44838

    I got as far as finding the "SummaryList", but can't figure out how to get to the next line and to parse it. Any help greatly appreciated! thanks.

    Code:
    Dim SummaryList As String = "SummaryList"
    Dim SummaryListSearch() As String = System.IO.File.ReadAllLines(ReadKlarf)
                    For Each line As String In SummaryListSearch
                        If line.Contains(SummaryList) Then
                            'MsgBox("jjjj")
                        End If
                    Next

  2. #2

    Thread Starter
    Junior Member
    Join Date
    May 2007
    Posts
    18

    Re: [2008] - pulling data from text file code help

    the msgbox was just to test that it found it, I know I need some code in there to go to the next line. next line doesn't seem to work in 08.. once I get to the next line, I'm unsure how to split the data as well. thanks again...

  3. #3
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,160

    Re: [2008] - pulling data from text file code help

    Hit F1 and it will atke you to a menu where if you click on Index and type
    "ReadAllText" you will come across some examples and explantions.

    Code:
    Imports System
    Imports System.IO
    
    Class Test
        Public Shared Sub Main()
            Try
                ' Create an instance of StreamReader to read from a file.
                Using sr As StreamReader = New StreamReader("TestFile.txt")
                    Dim line As String
                    ' Read and display the lines from the file until the end 
                    ' of the file is reached.
                    Do
                        line = sr.ReadLine()
                        Console.WriteLine(Line)
                    Loop Until line Is Nothing
                    sr.Close()
                End Using
            Catch E As Exception
                ' Let the user know what went wrong.
                Console.WriteLine("The file could not be read:")
                Console.WriteLine(E.Message)
            End Try
        End Sub
    End Class
    HTH
    toe

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