• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 仿照VC.NET的選擇行注釋宏

    發表于:2007-07-01來源:作者:點擊數: 標簽:
    聯系方式: ========================================================================== Sub BackSlashCommentOut() DESCRIPTION: Comment several selected rows of codes using double-backslash 開始定制注釋宏 Dim win set win = ActiveWindow Added

    聯系方式:

    ==========================================================================
    Sub BackSlashCommentOut()
    ´DESCRIPTION: Comment several selected rows of codes using double-backslash

    ´開始定制注釋宏
      Dim win
      set win = ActiveWindow
      ´Added by cadinfo, 2002,6,1 窗口關閉時無法使用宏,微軟有幾個自帶的宏存在BUG
      if VarType(win)=vbObject Then Exit Sub
      if win.type <> "Text" Then
        MsgBox "This macro can only be run when a text editor window is active."
      else
        ´Define three string variable
        TmpBlock = ""
        TmpRow = ""
        CmtBlock = Trim(ActiveDocument.Selection)
        LineNum = ActiveDocument.Selection.CurrentLine
       
        ´判斷是否為空,空退出宏
       
        if( Len(CmtBlock)=0) Then Exit Sub

        TypeOfFile = FileType(ActiveDocument)
        If TypeOfFile > 0 And TypeOfFile < 5 Then
          If TypeOfFile > 3 Then
            CommentType = "´CMT " ´ VBShit
          Else
            CommentType = "http://CMT "  ´C & C++ & C# &Java use the same
          End If

          ´注釋方式1 反斜杠backslash "http://CMT"

          ´---------處理開始----------------
          ´直到回車符=0
          Do While Instr (CmtBlock, vbLf) <> 0
            TmpRow = Left(CmtBlock, Instr(CmtBlock, vbLf))
            If Instr(TmpRow, CommentType) = 0 Then  ´ 如果沒有注釋標志,則添加注釋
            ´添加注釋標志"http://CMT "
              TmpBlock = TmpBlock + CommentType + TmpRow
            Else             ´ 如果有注釋標志,則刪除注釋
              TmpBlock = TmpBlock + Mid (TmpRow, Instr(TmpRow, CommentType)+Len(CommentType), Instr(TmpRow, vbLf))
            End If
            ´返回右邊的字符串,長度=Len(CmtBlock)-Instr(CmtBlock, vbLf)
            CmtBlock = Right(CmtBlock, (Len(CmtBlock)-Instr(CmtBlock, vbLf)))
          Loop

          ´最后一行如果沒有選中回車,則在行首添加注釋標志"http://CMT "
          if(Len(Trim(CmtBlock))<>0) Then
            If Instr(CmtBlock, CommentType) = 0 Then
              CmtBlock=CommentType+CmtBlock
            Else
              CmtBlock = Right (CmtBlock, Len(CmtBlock) - (Instr(CmtBlock, CommentType)+Len(CommentType))+1)
            End If
          End If
         
          CmtBlock = TmpBlock + Trim(CmtBlock)  ´拼接字符串
          ´---------到此處理完畢----------------

          ´ActiveDocument.Selection.Delete
          ActiveDocument.Selection = CmtBlock
          ActiveDocument.Selection.GotoLine LineNum
       
          ´添加語句選擇處理行   (ActiveDocument.Selection.SelectLine)
    ´     StartLine = ActiveDocument.Selection.TopLine
    ´     EndLine = ActiveDocument.Selection.BottomLine
    ´     For i = StartLine To EndLine
    ´       ActiveDocument.Selection.GoToLine i, dsSelect
    ´     Next

          ´另外一種注釋方式
          ´ActiveDocument.Selection = "/*" + ActiveDocument.Selection + "*/"
        Else
          MsgBox("File not supported or unknow error!")
        End If
      End If
    ´結束定制注釋宏
    End Sub
    ========================================================

    這次修改,完成了Toogle的功能,并且指出VS自帶的一些宏中存在BUG,

    在無文檔打開時調用宏會報錯,作者添加了判斷語句,屏蔽了這個問題。


    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>