您的位置:首页 > 编程语言

自己做的 VS.net 2005 sp1 程序注释使用的宏代码

2007-10-16 21:48 507 查看
主要功能是在代码头写注释和分组,大家可以参考了继续


Option Strict Off


Option Explicit Off


Imports System


Imports EnvDTE


Imports EnvDTE80


Imports System.Diagnostics




Public Module MyMacros




Sub AddWriter()


DTE.ActiveWindow.Selection.StartOfDocument()


DTE.ActiveDocument.Selection.Text = "/**********************************************"


DTE.ActiveDocument.Selection.NewLine()


DTE.ActiveDocument.Selection.Text = "程序员: 郑永丹 "


DTE.ActiveDocument.Selection.NewLine()


DTE.ActiveDocument.Selection.Text = "修改日期: " & DateTime.Now.ToString("yyyy-MM-dd")


DTE.ActiveDocument.Selection.NewLine()


DTE.ActiveDocument.Selection.Text = "程序内容:"


DTE.ActiveDocument.Selection.NewLine()


DTE.ActiveDocument.Selection.Text = " "


DTE.ActiveDocument.Selection.NewLine()


DTE.ActiveDocument.Selection.Text = " "


DTE.ActiveDocument.Selection.NewLine()


DTE.ActiveDocument.Selection.Text = " "


DTE.ActiveDocument.Selection.NewLine()


DTE.ActiveDocument.Selection.Text = " "


DTE.ActiveDocument.Selection.NewLine()


DTE.ActiveDocument.Selection.Text = "**********************************************/"


DTE.ActiveDocument.Selection.NewLine()


End Sub










Sub AddRegion()


Dim AddTextInfo As String() = New String(7) {"Private Object 私有对象", "Public Object 公有对象", "Private Var 私有变量", "Public Var 公有变量", "Public GETSET 公有属性", "Even Function 事件函数", "Private Method 私有方法", "Public Method 公有方法"}


Dim i As Integer = 0




For i = 0 To AddTextInfo.Length - 1


DTE.ActiveDocument.Selection.Text = "#region""" & AddTextInfo(i) & """"


DTE.ActiveDocument.Selection.NewLine()


DTE.ActiveDocument.Selection.Text = "#endregion"


DTE.ActiveDocument.Selection.NewLine()


DTE.ActiveDocument.Selection.NewLine()


Next




End Sub


End Module



使用方法

VS2005sp1 --IDE环境--Tool--Macros--Macros Explorer

选择 右键 复制代码过去 后保存退出

VS2005IDE环境 Tool--Customize--Commands--Macros 看到自己的两个功能了吧

把他们拉到工具栏,这个时候你是看不到的,继续在刚才的窗口

选择 Rearrange Commands--ToolBar--看到自己两方法 Modify Selection--Chang Buttion Image

ok 完工

到代码里测试下这两个按钮的功能吧。

好的代码注释是一个好的开始,我个人比较喜欢伪代码注释,也就是先写注释再写代码,这样思路不容易混,不用边写边想思路,注释先于代码,写得轻松,看得轻松。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: