Hi,

I have come to ask about "System.IO.StreamReader.ReadLine"
I want it to read line 1, then 2, then 3, and it keeps going for 20

Please just give me the code to read line 5 for example, then i will do the rest, here is the code for you to work on

Dim loadf As New System.IO.StreamReader("c:/text.txt")
        textbox5.Text = loadf.ReadLine()

Thats really all i know, please help

Thanks, Luke

to read from file line by line you need to use ReadLine method as you did , plus checking if you reached the end of file or not by Peek method

While loadf.Peek <> -1
            Line = loadf.ReadLine()
           ...
           ...
        End While

Please just give me the code to read line 5 for example, then i will do the rest,

i am not sure if I understand you, you want to write line 5 in the textbox? then in the while loop above check if you reached line 5 by counter then if yes show the line in textbox

n = 0
        While loadf.Peek <> -1
            n = n + 1
            Line = loadf.ReadLine()
            If n = 5 Then
                  TextBox1.Text = Line
            End If

        End While

Hi, yes i meant to write the text in line 5 to textbox1 for example. Please just confirm that the code you used would work,
Thanks,
Luke

:) to learn how to program you need to try at first then learn from your mistakes
however, yes that code should read the line 5 to textbox

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.