Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27349

Open Text File Twice

$
0
0
I'm a newbie to VB.net and am converting my VB6 application over..... don't be too harsh on my coding. I'm wanting to open a text file and count the records. Then open it again and load a rectangular array. Code is below. I receive the error (Local variable 'fsTT' is already declared in the current block.) How do I set up the second open/read operation with VB.net.

Thanks
Joe







Sub LoadTools()

' STEP 1 - Read .csv file to get a total number of tools.
vListCount = 0
Dim fsTT As New StreamReader(New FileStream(TTrack, FileMode.Open, FileAccess.Read))
Do While fsTT.Peek <> -1
vLine = Trim(fsTT.ReadLine)
vListCount += 1
Loop
fsTT.Close()


' STEP 2 - Load the Rectangular Array Tools
Dim Tools(vListCount, 4)
Dim fsTT As New StreamReader(New FileStream(TTrack, FileMode.Open, FileAccess.Read))
Dim i As Integer = 0
Do While fsTT.Peek <> -1
vLine = Trim(fsTT.ReadLine)
vLine = vLine.Remove(vLine.Length - 1, 1)
vLine = vLine.Remove(0, 1)
Dim Toolkit() As String = Split(vLine, "|", 5)
Tools(i, 0) = Toolkit(0) ' Kit
Tools(i, 1) = Toolkit(1) ' Box
Tools(i, 2) = Toolkit(2) ' Tool
Tools(i, 3) = Toolkit(3) ' Box ID
Tools(i, 4) = Toolkit(4) ' Location
i += 1
Loop
fsTT.Close()
MessageBox.Show(vListCount, "Total Count")
MessageBox.Show(Tools(512, 2))
End Sub

Viewing all articles
Browse latest Browse all 27349

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>