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 ?

Recommended Answers

All 3 Replies

How to do this code ?

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.

commented: I think it and you post it! +7

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
Try
'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
ListBox1.Items.Clear()
'Read files from text file
ListBox1.Items.AddRange(lines)
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
Loop
'View lines count in textbox
TXTCount.Text = DCount
CSVReader.Close()
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.