count the number of lines of code in a file, excluding blanks and comments also Count How many classes, Count How many function or procedures, how many lOC in each function or class, Count the lOC in each part to get the total program size ?

2 Years
Discussion Span
Last Post by jawahersaad

Question: How to get help on DaniWeb?

Answer: Show us that you have done something more than just copying your homework question here. Show us your code, and where you are getting stuck, and someone will help you.

Votes + Comments
I think it and you post it!

I have been done with this code but how to count class & funcation !

'Visual basic (.NET)
'Define library for read files
Imports System.IO
Public Class ETable1
Private Sub Button2_Click_1(sender As Object, e As EventArgs) Handles Button2.Click
'Identifier variable for file path that the user selects
Dim x As String
'Choose text file
OpenFileDialog1.Filter = "TIFF(*.txt;*.txt)|*.txt"
'If user choose text file the code will be run
If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
'Store file path
x = OpenFileDialog1.FileName
'Identifier variable for store lines value
Dim lines() As String = IO.File.ReadAllLines(x)
'Delete data from list
'Read files from text file
End If
Catch ex As Exception
'If file doesn't chooses or not found
MsgBox("file not found &   check the filename and try again", vbCritical)
End Try
'Identifier variable for store lines count
Dim DCount As Integer
'Identifier variable for store lines count value
Dim Row As String = ""
'Identifier variable for read file
Dim CSVReader As System.IO.StreamReader 'Puts file in CSVReader for Sorting
'Store file in Identifier variable
CSVReader = System.IO.File.OpenText(x)
'Read file
Do While Not CSVReader.EndOfStream() ' Loops until end of file or Stream
'Store lines in Identifier variable
Row = CSVReader.ReadLine()
'If row is not empty read line or  comment line
If Row <> "" And Mid(Row, 1, 1) <> "'" Then
'Lines count
DCount += 1
End If
'End this
'View lines count in textbox
TXTCount.Text = DCount
End Sub

Edited by Dani: Formatting fixed

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.