|
本帖最后由 boy8199 于 2021-11-16 10:45 编辑
方便 在程序运行中 在 立即窗口 看到 调用函数的 顺序.
可以做成插件,或者独立模块(需要搞一下,模块名判断)
需要引用 vb 扩展库(系统自带) vb for applications extensiblility
vb6 addin 插件工程, 复制代码, 需要略微修改一下. 即可.
vba 的话 要改一下 VBInstance.ActiveVBProject.VBComponents 的引用.
ActiveWorkbook.VBProject.VBComponents
'==================='
- Function ProcKindString(ProcKind As VBIDE.vbext_ProcKind) As String
- Debug.Print "--> frmAddIn : ProcKindString" '统一输出函数名
- Select Case ProcKind
- Case vbext_pk_Get
- ProcKindString = "Property Get"
- Case vbext_pk_Let
- ProcKindString = "Property Let"
- Case vbext_pk_Set
- ProcKindString = "Property Set"
- Case vbext_pk_Proc
- ProcKindString = "Sub Or Function"
- Case Else
- ProcKindString = "Unknown Type: " & CStr(ProcKind)
- End Select
- End Function
- Private Sub cmdCommand1_Click()
- Debug.Print "--> frmAddIn : cmdCommand1_Click" '统一输出函数名
- Dim i As Long: Dim j As Long: Dim k As Long
- Dim VBCs As VBComponents
- Dim cm As CodeModule
- Dim ProcName As String
- Dim ProcKind As VBIDE.vbext_ProcKind
- Dim pbl As Long: Dim tempStr As String: Dim pbl1 As Long 'pbl1 函数身体+1行
-
- txtText1.Text = ""
-
- Set VBCs = VBInstance.ActiveVBProject.VBComponents
-
-
- For i = 1 To VBCs.Count
-
- Set cm = VBCs(i).CodeModule
- txtText1.Text = txtText1.Text & VBCs(i).Type & ":" & VBCs(i).Name & "--------" & vbCrLf
-
- j = 0
- With cm
- j = .CountOfDeclarationLines + 1
- Do Until j >= .CountOfLines
- ProcName = .ProcOfLine(j, ProcKind)
-
- pbl = .ProcBodyLine(ProcName, ProcKind)
- txtText1 = txtText1 & ProcName & " | " & ProcKindString(ProcKind) & " | " _
- & pbl & vbCrLf
-
- j = .ProcStartLine(ProcName, ProcKind) + .ProcCountLines(ProcName, ProcKind)
-
- For k = pbl To j
- tempStr = .Lines(k, 1)
- If Right(tempStr, 1) <> "_" Then
- pbl1 = k + 1
- Exit For
- End If
- Next
-
- For k = pbl1 To j
- tempStr = Trim(.Lines(k, 1))
-
- If Len(tempStr) > 0 Then
- If (Left(tempStr, 11) = "Debug.Print") And (Right(tempStr, 8) = "'统一输出函数名") Then
-
- Call cm.DeleteLines(k, 1)
- k = k - 1
- j = j - 1
- End If
- End If
- Next
-
- Call cm.InsertLines(pbl1, " " & "Debug.Print """ & "--> " _
- & VBCs(i).Name & " : " & ProcName & """ '统一输出函数名")
-
- j = .ProcStartLine(ProcName, ProcKind) + .ProcCountLines(ProcName, ProcKind) + 1
- Loop
- End With
- txtText1.Text = txtText1.Text & vbCrLf
-
- Next
- End Sub
复制代码
'==========='
|
|