general question on code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello. The boss is beginning to ask about the number of lines of code that
there is in different Access databases that have been created and those
currently under construction. Does Access have a way of determining that or
is there another method for determining (other then actually counting)?
Thanks.
*** John
 
JohnE said:
Hello. The boss is beginning to ask about the number of lines of code that
there is in different Access databases that have been created and those
currently under construction. Does Access have a way of determining that or
is there another method for determining (other then actually counting)?


No simple way to do that.

Here's a procedure you can put in a module and call from the
immediate window:

Public Function LinesOfCode() As Long
Dim dbCur As Database
Dim doc As Document

Set dbCur = CurrentDb
' Count lines of code in Modules
For Each doc In dbCur.Containers("Modules").Documents
DoCmd.OpenModule doc.Name
LinesOfCode = LinesOfCode + _
LinesInModule(Modules(doc.Name))
DoCmd.Close acModule, doc.Name, acSaveNo
Next doc

' Count lines of code in Forms
For Each doc In dbCur.Containers("Forms").Documents
DoCmd.OpenForm doc.Name, acDesign
With Forms(doc.Name)
If .HasModule Then
LinesOfCode = LinesOfCode + _
LinesInModule(.Module)
End If
End With
DoCmd.Close acForm, doc.Name, acSaveNo
Next doc

' Count lines of code in Reports
For Each doc In dbCur.Containers("Reports").Documents
DoCmd.OpenReport doc.Name, acDesign
With Reports(doc.Name)
If .HasModule Then
LinesOfCode = LinesOfCode + _
LinesInModule(.Module)
End If
End With
DoCmd.Close acReport, doc.Name, acSaveNo
Next doc

Set dbCur = Nothing
End Function


Public Function LinesInModule(mdl As Module) As Long
Dim lngLineNo As Long
Dim strLine As String

For lngLineNo = 1 To mdl.CountOfLines
strLine = Trim$(mdl.Lines(lngLineNo, 1))
If strLine <> "" And Left$(strLine, 1) <> "'" Then
LinesInModule = LinesInModule + 1
End If
Next lngLineNo
End Function

Be sure to tell your boss that lines of code is a silly
measurement of anything ;-)
 
This is a link to MZ Tools. One of the utilities included is Statistics
which will give you that information. You will also find this tool very
valuable for development.

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

Would it be inappropriate for me to point out your boss is a moron?
Nobody in their right mind has attempted to measure a developer's
productivity using code line counting in the last 15 to 20 years.
 
Klatuu (and Marshall) thank you both for your info.

K - you ask if it would be inappropriate, I would say yes. But you are
correct and not the first person to say that. It was found that the person
who is asking for the info has very little if no experience in IT at all.
The person also manages several other depts.

Thanks again to you both.
*** John
 
Back
Top