ProcBodyLine Property

Applies To

Module object.

Description

The ProcBodyLine property returns a Long value containing the number of the line at which the body of a specified procedure begins in a standard module or a class module. The body of a procedure begins with the procedure definition, denoted by one of the following:

  • A Sub statement.
  • A Function statement.
  • A Property Get statement.
  • A Property Let statement.
  • A Property Set statement.
Setting

object.ProcBodyLine(procname, prockind)

The ProcBodyLine property uses the following settings.

Setting

Description

object

A Module object.

procname

A string expression that evaluates to the name of a procedure in the module.

prockind

An intrinsic constant that specifies the type of procedure. The constant may be one of the following values.

Constant

Description

vbext_pk_Get

A Property Get procedure.

vbext_pk_Let

A Property Let procedure.

vbext_pk_Proc

A Sub or Function procedure.

vbext_pk_Set

A Property Set procedure.


The ProcBodyLine property is available only by using Visual Basic and is read-only.

Remarks

The ProcBodyLine property returns a number that identifies the line on which the procedure definition begins. In contrast, the ProcStartLine property returns a number that identifies the line at which a procedure is separated from the preceding procedure in a module. Any comments or compilation constants that precede the procedure definition (the body of a procedure) are considered part of the procedure, but the ProcBodyLine property ignores them.

Note The ProcBodyLine property treats Sub and Function procedures similarly, but distinguishes between each type of Property procedure.

See Also

Function statement, ProcCountLines property, ProcOfLine property, ProcStartLine property, Property Get statement, Property Let statement, Property Set statement, Sub statement.

Example

The following function prints information about a specified procedure in a module to the Debug window:

Function ProcLineInfo(strModuleName As String, strProcName As String)
    Dim mdl As Module
    Dim lngStartLine As Long, lngBodyLine As Long
    Dim lngCount As Long, lngEndProc As Long

    ' Open specified Module object.
    DoCmd.OpenModule strModuleName
    ' Return reference to Module object.
    Set mdl = Modules(strModuleName)

    ' Count lines in procedure.
    lngCount = mdl.ProcCountLines(strProcName, vbext_pk_Proc)
    ' Determine start line.
    lngStartLine = mdl.ProcStartLine(strProcName, vbext_pk_Proc)
    ' Determine body line.
    lngBodyLine = mdl.ProcBodyLine(strProcName, vbext_pk_Proc)
    Debug.Print

    ' Print all lines in procedure preceding body line.
    Debug.Print "Lines preceding procedure " & strProcName & ": "
    Debug.Print mdl.Lines(lngStartLine, lngBodyLine - lngStartLine)

    ' Determine line number of last line in procedure.
    lngEndProc = (lngBodyLine + lngCount - 1) - Abs(lngBodyLine - lngStartLine)

    ' Print all lines in body of procedure.
    Debug.Print "Body lines: "
    Debug.Print mdl.Lines(lngBodyLine, (lngEndProc - lngBodyLine) + 1)
End Function
You could call this function from the Northwind sample database with a procedure such as the following:

Sub GetProcInfo()
    ProcLineInfo "Utility Functions", "IsLoaded"
End Sub