Amount of code

hog

Senior Contributor
Joined
Mar 17, 2003
Messages
984
Location
UK
Is there a simply way to have VS calcualte how any lines of code are contained in a project?
 
I dont think so, i have tried to find this but with no luck...

I cant think of any way other than adding the number of lines for
each class or module in your project .
 
here ya go , you would have to account for how many forms you have , but you should get the idea :
Visual Basic:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim str(2) As String, x As Integer
        Dim strLocation As String = Application.StartupPath
        strLocation = Replace(strLocation, "bin", "")
        str(1) = strLocation & "Form1.vb" : str(2) = strLocation & "Form2.vb"

        Dim sr(2) As StreamReader
        For x = 1 To 2
            sr(x) = New StreamReader(New FileStream(str(x), FileMode.Open))
            TextBox1.Text = sr(x).ReadToEnd()
            MessageBox.Show("The Number of Lines in " & str(x) & " is:" & Chr(10) & TextBox1.Lines.Length)
            sr(x).Close()
        Next
    End Sub
 
I just do a search in all files, for * it brings back everything and a final value. It includes resource files and form setups etc etc, but its quick and simple.
 
Back
Top