Hi All,

I have a text document that am pulling infomation out of.
i only want to collect the information after the = sysmbol which is on each line.

here is the code so far

Dim FileName As String = "C:\test.txt"
        Dim TextFromTheFile As String ' Whole text
        Dim Lines() As String ' File splitted to lines
        Dim LineSeparator() As String = {Environment.NewLine} ' Line separator 'character'
        ' Use My namespace
        If My.Computer.FileSystem.FileExists(FileName) Then
            ' Read the file   
            TextFromTheFile = My.Computer.FileSystem.ReadAllText(FileName)
            ' Get lines. I used StringSplitOptions that removes empty lines  
            Lines = TextFromTheFile.Split(LineSeparator, System.StringSplitOptions.RemoveEmptyEntries)
            ' Now you have Lines() array ready  

            Me.TextBox1.Text = Lines(0)
            'TextBox2.Text = Lines(1)
            ' and so on...
            ' The file not found error  
            MessageBox.Show("File Does Not Exist", "File Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End If

lines(0) now contains server=localhost
i only want to show localhost
lines(1) contacts database=maintsystem and i only want to collect maintsystem

is this even possible?

6 Years
Discussion Span
Last Post by Mike Bishop

Maybe on line 12 of your example you can add:

Dim Parts() As String = Lines(0).Split("="c)

then show the Parts(1)
or change the line 14 to

Me.TextBox1.Text=Lines(0).SubString(Lines(0).IndexOf("="c) + 1)

The first solution can fail if no '=' sign exists.
The second solution will show all the line content is no '=' sign exists.

Hope this helps

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.