1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
'============= FNC001 modDocumentClass =================================
' functions: =
' (01) document a class =
'=======================================================================
' method description:
' This function documents a class.
' created 09-NOV-2007
' modified 09-NOV-2007
' uses:
' Left(),Right(),Trim()
'
' Application::()
' inputs:
' strClassName: class module name
' outputs:
' modDocumentClass: returned function value
' locals:
' i: counter
' nLines: count of lines
'
' b2Continue: key indicating if to continue a line
' bTodo: todo key
'
' str1: string
' strLine: string of a code line
' strret: return string
'
' xobj: object
' notes:
' Source:
' http://www.developpez.net/forums/member.php?u=27262
' M. Pierre Fauconnier.
'
'=======================================================================
Function modDocumentClass(strClassName As String) As String
'
' global variables:
'
'
' local variables:
'
Dim i As Long, nLines As Long
'
Dim b2Continue As Boolean, bTodo As Boolean
'
Dim str1 As String, strLine As String, strret As String
'
Dim xobj As Object
'
' function body:
'
str1 = Application.GetOption("Project Name")
Set xobj = _
Application.VBE.VBProjects(str1).VBComponents(strClassName)
nLines = xobj.CodeModule.CountOfLines
b2Continue = False
strret = ""
'
For i = 1 To nLines
'
strLine = xobj.CodeModule.Lines(i, 1)
str1 = Trim(strLine)
'
If (Left(str1, 3)) = "Sub" Then
bTodo = True
ElseIf (Left(str1, 12) = "Property Get") Then
bTodo = True
ElseIf (Left(str1, 12) = "Property Let") Then
bTodo = True
ElseIf (Left(str1, 8) = "Function") Then
bTodo = True
ElseIf (Left(str1, 15) = "Public Function") Then
bTodo = True
ElseIf (b2Continue) Then
bTodo = True
Else
bTodo = False
End If
'
If (bTodo) Then
strret = strret & strLine & vbCrLf
b2Continue = (Right(str1, 1) = "_")
End If
'
Next
'
Set xobj = Nothing
'
' set function value:
'
modDocumentClass = strret
'
' exit the function:
'
End Function |
Partager