Applies To Module object.
Description
The ProcOfLine property returns a string containing the name of the procedure that contains a specified line in a standard module or a class module. The body of a procedure begins with the procedure definition, denoted by one of the following:
Setting
object.ProcOfLine(line, pprockind)
The ProcOfLine property uses the following settings.Setting | Description |
object | A Module object. |
line | A Long that specifies the number of a line in the module. |
pprockind | An Long value that indicates the type of procedure containing the line specified by the line argument. When you return the value of the ProcOfLine property, the value of the pprockind argument is set to an intrinsic constant that specifies the type of procedure the line belongs to. The constant may be one of the following values. | ||
Constant | Value | Description | |
vbext_pk_Get | 3 | A Property Get procedure. | |
vbext_pk_Let | 1 | A Property Let procedure. | |
vbext_pk_Proc | 0 | A Sub or Function procedure. | |
vbext_pk_Set | 2 | A Property Set procedure. |
See Also Function statement, ProcBodyLine property, ProcCountLines property, ProcStartLine property, Property Get statement, Property Let statement, Property Set statement, Sub statement.
Example The following function procedure lists the names of all procedures in a specified module:Function AllProcs(strModuleName As String)
Dim mdl As Module
Dim lngCount As Long, lngCountDecl As Long, lngI As Long
Dim strProcName As String, astrProcNames() As String
Dim intI As Integer, strMsg As String
Dim lngR As Long
' Open specified Module object.
DoCmd.OpenModule strModuleName
' Return reference to Module object.
Set mdl = Modules(strModuleName)
' Count lines in module.
lngCount = mdl.CountOfLines
' Count lines in Declaration section in module.
lngCountDecl = mdl.CountOfDeclarationLines
' Determine name of first procedure.
strProcName = mdl.ProcOfLine(lngCountDecl + 1, lngR)
' Initialize counter variable.
intI = 0
' Redimension array.
ReDim Preserve astrProcNames(intI)
' Store name of first procedure in array.
astrProcNames(intI) = strProcName
' Determine procedure name for each line after declarations.
For lngI = lngCountDecl + 1 To lngCount
' Compare procedure name with ProcOfLine property value.
If strProcName <> mdl.ProcOfLine(lngI, lngR) Then
' Increment counter.
intI = intI + 1
strProcName = mdl.ProcOfLine(lngI, lngR)
ReDim Preserve astrProcNames(intI)
' Assign unique procedure names to array.
astrProcNames(intI) = strProcName
End If
Next lngI
strMsg = "Procedures in module '" & strModuleName & "': " _
& vbCrLf & vbCrLf
For intI = 0 To UBound(astrProcNames)
strMsg = strMsg & astrProcNames(intI) & vbCrLf
Next intI
' Dialog box listing all procedures in module.
MsgBox strMsg
End Function
You could call this function with a procedure such as the following:
Sub GetAllProcs()
AllProcs "Utility Functions"
End Sub