|
-
Sep 19th, 2010, 01:26 PM
#1
Thread Starter
Addicted Member
How to read text file line by line?
Ok, I saw this code on the net
Dim sFileName As String
Dim srFileReader As System.IO.StreamReader
Dim sInputLine As String
sFileName = "D:\Users\Arben\Desktop\SerieA.txt"
srFileReader = System.IO.File.OpenText(sFileName)
sInputLine = srFileReader.ReadLine()
Do Until sInputLine Is Nothing
System.Console.WriteLine(sInputLine)
sInputLine = srFileReader.ReadLine()
Loop
Now, I have some labels that I want the text on each of them to be the text on each line of the .txt file
now I write this
Label21.Text = sInputLine
Label22.Text = sInputLine
Label23.Text = sInputLine
under the code I pasted at the top, but I get the text on line1 in all labels, like all labels become 1, while the text should be 1, 2, 3 and so on. So anyone can help me do that, each label gets the value of the next line in the txt file
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|