CountOfLines, CountOfDeclarationLines Properties Example

The following example counts the number of lines and declaration lines in each standard module in the Modules collection. Note that the Modules collection contains only modules that are open in the module editor.

Function ModuleLineTotal(strModuleName As String)
    Dim mdl As Module

    ' Open module to include in Modules collection.
    DoCmd.OpenModule strModuleName
    ' Return reference to Module object.
    Set mdl = Modules(strModuleName)
    ' Print number of lines in module.
    Debug.Print "Number of lines: ", mdl.CountOfLines
    ' Print number of declaration lines.
    Debug.Print "Number of declaration lines: ", _
        mdl.CountOfDeclarationLines
End Function