步驟:
1、在記事本中編輯好類似下面的腳本代碼:
01 Imports System
02 Imports EnvDTE
03 Imports EnvDTE80
04 Imports EnvDTE90
05 Imports EnvDTE90a
06 Imports EnvDTE100
07 Imports System.Diagnostics
08
09 Public Module ModuleTop
10 Sub AddFunComment()
11 Dim DocSel As EnvDTE.TextSelection
12 DocSel = DTE.ActiveDocument.Selection
13 DocSel.NewLine()
14 DocSel.Text = "/*******************************************************************"
15 DocSel.NewLine()
16 DocSel.Text = "* 版權所有: "
17 DocSel.NewLine()
18 DocSel.Text = "* 類 名 稱: "
19 DocSel.NewLine()
20 DocSel.Text = "* 功 能: "
21 DocSel.NewLine()
22 DocSel.Text = "* 參 數: "
23 DocSel.NewLine()
24 DocSel.Text = "* 返 回 值: "
25 DocSel.NewLine()
26 DocSel.Text = "* 作 者:XXXXX"
27 DocSel.NewLine()
28 DocSel.Text = "* 電子郵箱:[email protected]"
29 DocSel.NewLine()
30 DocSel.Text = "* 創建日期: " + System.DateTime.Now.ToString()
31 DocSel.NewLine()
32 DocSel.Text = "*******************************************************************/"
33 End Sub
34
35 End Module
2、VS2010 IDE -> 工具 -> 宏 -> 新建宏項目,選擇要保存的位置。然後將要上面的腳本複製進去,保存即可。
3、爲你編寫的宏綁定快捷鍵,VS2005 IDE -> 工具 -> 選項 -> 在左邊列表中選擇“鍵盤” -> 在右邊的“顯示命令包含”中,選擇你創建宏-> 將光標定位到”按快捷鍵”處 -> 輸入你想命名的快捷鍵,比如”Alt+C”,保存即可。
注:類內部註釋
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
Public Module ModuleContent
Sub AddFunComment()
Dim DocSel As EnvDTE.TextSelection
DocSel = DTE.ActiveDocument.Selection
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = " #region<構造方法和析構方法>"
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#endregion<構造方法和析構方法>"
DocSel.NewLine()
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#region<常量>"
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#endregion<常量>"
DocSel.NewLine()
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#region<變量>"
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#endregion<變量>"
DocSel.NewLine()
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#region<屬性>"
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#endregion<屬性>"
DocSel.NewLine()
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#region<方法>"
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#endregion<方法>"
DocSel.NewLine()
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#region<事件>"
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#endregion<事件>"
End Sub
End Module
其餘步驟同上。