Table of contents
TOC
Collapse the table of content
Expand the table of content

Module.CountOfLines Property (Access)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

The CountOfLines property returns a Long value indicating the number of lines of code in a standard module or class module. Read-only Long.

Syntax

expression. CountOfLines

expression A variable that represents a Module object.

Remarks

Lines in a module are numbered beginning with 1.

The line number of the last line in a module is the value of the CountOfLines property.

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.

Public Sub ModuleLineTotal(ByVal 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 Sub

See also

Concepts

Module Object

© 2018 Microsoft