943,901 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 1855
  • VB.NET RSS
Sep 10th, 2008
0

ReadLine Question, URGENT

Expand Post »
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
lukechris is offline Offline
17 posts
since Aug 2008
Sep 10th, 2008
0

Re: ReadLine Question, URGENT

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

VB.NET Syntax (Toggle Plain Text)
  1. While loadf.Peek <> -1
  2. Line = loadf.ReadLine()
  3. ...
  4. ...
  5. End While

Quote ...
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

VB.NET Syntax (Toggle Plain Text)
  1. n = 0
  2. While loadf.Peek <> -1
  3. n = n + 1
  4. Line = loadf.ReadLine()
  5. If n = 5 Then
  6. TextBox1.Text = Line
  7. End If
  8.  
  9. End While
Last edited by manal; Sep 10th, 2008 at 7:22 pm.
Reputation Points: 37
Solved Threads: 17
Junior Poster
manal is offline Offline
122 posts
since Mar 2006
Sep 11th, 2008
0

Re: ReadLine Question, URGENT

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
lukechris is offline Offline
17 posts
since Aug 2008
Sep 11th, 2008
0

Re: ReadLine Question, URGENT

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
Reputation Points: 37
Solved Threads: 17
Junior Poster
manal is offline Offline
122 posts
since Mar 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Connecting VB .NET with SQL Dbase
Next Thread in VB.NET Forum Timeline: paycheck calculator





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC