Solved

Count Lines of Source

Posted on 2006-10-27
6
258 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 5

Expert Comment

by:tsay
ID: 17819047
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
ID: 17819327
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
ID: 17819547
Sounds like the current way is easiest -- go to the bottom of the file and see what line number it says. :(
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 70

Accepted Solution

by:
Éric Moreau earned 300 total points
ID: 17819586
Hi tsay,

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

Cheers!
0
 
LVL 21

Expert Comment

by:mastoo
ID: 17820305
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
ID: 17821611
BTW, I love using CodeRush and RefactorPro.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

615 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