Solved

Count Lines of Source

Posted on 2006-10-27
6
251 Views
Last Modified: 2012-08-14
Is there an easy way to count the number of lines of source in VB.NET 2005? Just the standard files (not the additional ones shown when selecting "Show All Files").
0
Comment
Question by:GivenRandy
6 Comments
 
LVL 5

Expert Comment

by:tsay
Comment Utility
I don't think you can do this in visual studio. What you can do is copy the source, paste it in MS Word en count the lines using Tools - Word Count. Ofcourse Word will  paste sentences over multiple lines so the number won't be exact but it'll give you an idea...
HTH
0
 
LVL 34

Assisted Solution

by:Sancler
Sancler earned 200 total points
Comment Utility
A .vb file is just a textfile with a different extension.  So you can read it into a string, split it on crlf and count the number of elements in the resulting array.  That will then include all the empty lines, comments, etc.  But you can code to exclude those if you want something more refined.  Here's a little demo of the rough version.  One form, an OpenFileDialog (fd1) and a button

Imports System.IO
Imports System.Text.RegularExpressions
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        fd1.ShowDialog()
        Dim myFile As String = fd1.FileName
        Dim sr As New StreamReader(myFile)
        Dim contents As String = sr.ReadToEnd
        Dim lines() As String = Regex.Split(contents, vbCrLf)
        MsgBox(lines.Length)
    End Sub
End Class

Roger
0
 
LVL 9

Author Comment

by:GivenRandy
Comment Utility
Sounds like the current way is easiest -- go to the bottom of the file and see what line number it says. :(
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 69

Accepted Solution

by:
Éric Moreau earned 300 total points
Comment Utility
Hi tsay,

I use http://www.mztools.com/index.htm

Cheers!
0
 
LVL 21

Expert Comment

by:mastoo
Comment Utility
You can go to a command prompt and:

Type *.vb > myfile.txt

And then open myfile.txt in VS, go to the bottom, and get the total line count for that project/directory.
0
 
LVL 9

Author Comment

by:GivenRandy
Comment Utility
BTW, I love using CodeRush and RefactorPro.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

763 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now