[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Visual Basic .net count number of lines in a text file

Posted on 2011-04-23
2
Medium Priority
?
519 Views
Last Modified: 2012-05-11
Hi
How do I count hte number of lines in a text file with visual basic .net (2010)
0
Comment
Question by:sykotex
2 Comments
 
LVL 18

Accepted Solution

by:
Rajar Ahmed earned 2000 total points
ID: 35452476
try this
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim FSO = CreateObject("Scripting.FileSystemObject")
        Dim file = FSO.OpenTextFile("test.txt", 1) ' Give Corect Path Here
        File.ReadAll()
        Label1.Text = "Number Of Line = " & file.line.ToString()
End Sub

Open in new window

0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35452542
Another approach

IO.File.ReadAllLines("path").Count

0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question