zoukankan      html  css  js  c++  java
  • vb6 Vba 插件 添加输出函数名到立即窗口 Addin

    写了一个插件 vba vb6

    把每一个 函数或过程 都 添加输出函数名到立即窗口的代码. 可以看到 函数调用的过程.

    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 """ & "--> " & ProcName & """                 '统一输出函数名")
                                  
                j = .ProcStartLine(ProcName, ProcKind) + .ProcCountLines(ProcName, ProcKind) + 1
              Loop
          End With
         txtText1.Text = txtText1.Text & vbCrLf
         
        Next
  • 相关阅读:
    描述一下 JVM 加载 class 文件的原理机制?
    Java 中会存在内存泄漏吗,请简单描述
    关于同步机制的一些见解
    Mybatis 一对一,一对多,多对一,多对多的理解
    关于JavaBean实现Serializable接口的见解
    Python 文件I/O
    Python 模块
    Python 函数
    Python time tzset()方法
    Python time time()方法
  • 原文地址:https://www.cnblogs.com/MadeInChinese/p/15557118.html
Copyright © 2011-2022 走看看