Click here to Skip to main content
15,901,426 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need your guidance to complete a small project I am working on.

Basically, I need to use VB.NET to open a text file; read the 1st 7 lines in the file while splitting each line into arrays and assign a variable to each segment. After, I will need to replace certain variables and write back to text file.

This is the code I have attempted below:
Private Sub btnFixation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFixation.Click
        'read file line by line; parse lines
        Dim myLine As String = ""
        Dim LineOfPeas As String
        Dim t As Integer
        Dim aryPeasLine(6) As String
        Dim objReader As New System.IO.StreamReader(Me.lblPeasFile.Text)

        Do While objreader.peek() <> -1
            PeasLine = PeasLine & objReader.ReadLine() & vbNewLine


        LineOfPeas = myLine
        aryPeasLine = LineOfPeas.Split("*")
        LineOfPeas = LineOfPeas.Replace("STUBBS", "FUGEES")
        For t = 0 To 6

        Next t
    End Sub

Updated 6-Apr-12 7:08am
André Kraak 6-Apr-12 13:08pm    
Edited question:
Added pre tags

1 solution

The first thing I noticed was that you declare "myLine" as an empty string, but then you never assign a value to it. "PeasLine" is assigned values inside the do-while, but then "PeasLine" is never used again. You then assign the empty 'myLine' to LineOfPeas. The array has nothing to find based on your split, so the result is... not what you wanted.

Hopefully that will get you on the path to a solution. Best Regards! Jay
Share this answer
IvanIT 8-Apr-12 12:58pm    
Thanks Jay. I will review and revise my steps.


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900