首页 > 代码库 > vc6.0批量加注释
vc6.0批量加注释
MATLAB批量加注释的方法非常简单明了,加注释是ctrl+R,去注释是ctrl+T
然后在VC中我对一条一条加注释的方法非常烦恼,我想也许会有简单的方法可以批量家注释。果然,先贴代码
1 ‘------------------------------------------------------------------------------ 2 ‘FILE DESCRIPTION: 给vc++6.0中添加和取消批量注释的功能 3 ‘------------------------------------------------------------------------------ 4 Sub SetSelNote()‘Sun DESCRIPTION: 过程SetSelNote 用于将选中的文本转换为注释 5 dim CurWin ‘当前获得的窗口 6 set CurWin = ActiveWindow 7 if CurWin.type<>"Text" Then ‘判断当前窗口是否是文本窗口 8 MsgBox "当前窗口不是代码窗口" 9 else10 NoteType = "//"11 BeginLine = ActiveDocument.Selection.TopLine12 EndLine = ActiveDocument.Selection.BottomLine13 if EndLine < BeginLine then14 Line = BeginLine15 BeginLine = EndLine16 EndLine = Line17 else18 for row = BeginLine To EndLine19 ActiveDocument.Selection.GoToLine row20 ActiveDocument.Selection.SelectLine‘选中当前行21 ActiveDocument.Selection = NoteType + ActiveDocument.Selection22 Next23 End if24 End if25 End Sub26 27 Sub CancelSelNote()28 dim CurWin ‘当前获得的窗口29 set CurWin = ActiveWindow30 if CurWin.type<>"Text" Then ‘判断当前窗口是否是文本窗口31 MsgBox "当前窗口不是代码窗口"32 else33 BeginLine = ActiveDocument.Selection.TopLine34 EndLine = ActiveDocument.Selection.BottomLine35 if EndLine < BeginLine then36 Line = BeginLine37 BeginLine = EndLine38 EndLine = Line39 else40 for row = BeginLine To EndLine41 ActiveDocument.Selection.GoToLine row42 ActiveDocument.Selection.SelectLine‘选中当前行43 SelBlock = ActiveDocument.Selection44 Trim(SelBlock)45 pos = instr(SelBlock,"//")46 if pos <>0 then47 RightBlock = Right(SelBlock, Len(SelBlock)-2)48 ActiveDocument.Selection = RightBlock49 End if50 Next51 End if52 End if53 End Sub
具体方法参照http://blog.163.com/fantasy_sunny/blog/static/195918212201222504855353/
感谢原作者辛苦贴图。
vc6.0批量加注释
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。