User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 425,819 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,031 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser: Programming Forums
Views: 503 | Replies: 1
Reply
Join Date: Apr 2008
Posts: 19
Reputation: mansi sharma is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
mansi sharma mansi sharma is offline Offline
Newbie Poster

read TextFile Line by Line

  #1  
Jul 15th, 2008
hey,I know the foll. Method to read the textfile line by line. & it is also working Fine. But I want to know that method which includes EOF(End Of File).
Can Somebody tell me that method.
  1. sFilename = "C:\Listview.txt"
  2. If Dir(sFilename.ToString) <> "" Then
  3. sFileReader = System.IO.File.OpenText(sFilename)
  4. sInputLine = sFileReader.ReadLine()
  5. Do Until sInputLine Is Nothing
  6. sInputLine = sFileReader.ReadLine()
  7. Loop
  8. End If
Last edited by Tekmaven : Jul 16th, 2008 at 3:05 am. Reason: Code tags
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2002
Location: West Virginia
Posts: 388
Reputation: waynespangler is on a distinguished road 
Rep Power: 6
Solved Threads: 40
waynespangler waynespangler is offline Offline
Posting Whiz

Re: read TextFile Line by Line

  #2  
Jul 15th, 2008
How are saving sImputLine? As I see you are overwritting it with each read.
I use:
    Dim ary As String()

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If My.Computer.FileSystem.FileExists("c:\test.txt") Then
            Dim str As String = My.Computer.FileSystem.ReadAllText("c:\test.txt")
            str.Split(ary, vbNewLine)
        End If
    End Sub
Now all your data is in an array.
Wayne

It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb VB.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the VB.NET Forum

All times are GMT -4. The time now is 4:12 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC