ReadLine Question, URGENT

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2008
Posts: 16
Reputation: lukechris is an unknown quantity at this point 
Solved Threads: 0
lukechris lukechris is offline Offline
Newbie Poster

ReadLine Question, URGENT

 
0
  #1
Sep 10th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 121
Reputation: manal is an unknown quantity at this point 
Solved Threads: 17
manal's Avatar
manal manal is offline Offline
Junior Poster

Re: ReadLine Question, URGENT

 
0
  #2
Sep 10th, 2008
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

  1. While loadf.Peek <> -1
  2. Line = loadf.ReadLine()
  3. ...
  4. ...
  5. 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

  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.
"give only what u willing to receive "
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 16
Reputation: lukechris is an unknown quantity at this point 
Solved Threads: 0
lukechris lukechris is offline Offline
Newbie Poster

Re: ReadLine Question, URGENT

 
0
  #3
Sep 11th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 121
Reputation: manal is an unknown quantity at this point 
Solved Threads: 17
manal's Avatar
manal manal is offline Offline
Junior Poster

Re: ReadLine Question, URGENT

 
0
  #4
Sep 11th, 2008
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
"give only what u willing to receive "
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC