自己做的 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 完工
到代码里测试下这两个按钮的功能吧。
好的代码注释是一个好的开始,我个人比较喜欢伪代码注释,也就是先写注释再写代码,这样思路不容易混,不用边写边想思路,注释先于代码,写得轻松,看得轻松。
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 完工
到代码里测试下这两个按钮的功能吧。
好的代码注释是一个好的开始,我个人比较喜欢伪代码注释,也就是先写注释再写代码,这样思路不容易混,不用边写边想思路,注释先于代码,写得轻松,看得轻松。
相关文章推荐
- 使用vs的性能分析asp.net程序时报错的解决方法 (转载)
- VS C#.net 2005 程序打包(收藏)
- 怎么节省安装 VS.net 2005 Sp1的时间
- 使用VS.NET来制作安装程序
- 安装程序自动注册控件到工具箱 vs.net 2005
- VS.NET2005使用体验(一)
- Crystal Support 之最高阅览量文章:怎样部署使用 Crystal Reports 和 VS.NET 的程序?(翻译:海波.NET)
- vs2005下使用sql 2000或其他数据库作为membership的默认提供程序
- Visual Studio .NET使用技巧手册读书笔记之使用VS.NET 2005
- VS 2005使用map文件查找程序崩溃原因
- vs.net 2005 sp1 安装经验收集
- Vista 中,使用VS 2005调试程序没有权限的问题?
- VS 2005使用map文件查找程序崩溃原因
- 关于VS.NET 2005 外接程序开发
- 在VS.NET中使用clickonce技术开发Winform程序
- vs. 2005也可以使用web application project, 如何把asp.net ajax特性加入呢?
- Windows 7 使用 VS.NET 2003 时遇到“LNK1201: 写入程序数据库时出错”的解决方案 修正版
- 使用JBuilder 2005创建程序注释(1)
- 解决vs.net 2005下MDI程序菜单合并
- VS 2005 (.Net 2.0) 提供的Login1的使用方法