标签:des style blog http io color os sp for
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 else 10 NoteType = "//" 11 BeginLine = ActiveDocument.Selection.TopLine 12 EndLine = ActiveDocument.Selection.BottomLine 13 if EndLine < BeginLine then 14 Line = BeginLine 15 BeginLine = EndLine 16 EndLine = Line 17 else 18 for row = BeginLine To EndLine 19 ActiveDocument.Selection.GoToLine row 20 ActiveDocument.Selection.SelectLine‘选中当前行 21 ActiveDocument.Selection = NoteType + ActiveDocument.Selection 22 Next 23 End if 24 End if 25 End Sub 26 27 Sub CancelSelNote() 28 dim CurWin ‘当前获得的窗口 29 set CurWin = ActiveWindow 30 if CurWin.type<>"Text" Then ‘判断当前窗口是否是文本窗口 31 MsgBox "当前窗口不是代码窗口" 32 else 33 BeginLine = ActiveDocument.Selection.TopLine 34 EndLine = ActiveDocument.Selection.BottomLine 35 if EndLine < BeginLine then 36 Line = BeginLine 37 BeginLine = EndLine 38 EndLine = Line 39 else 40 for row = BeginLine To EndLine 41 ActiveDocument.Selection.GoToLine row 42 ActiveDocument.Selection.SelectLine‘选中当前行 43 SelBlock = ActiveDocument.Selection 44 Trim(SelBlock) 45 pos = instr(SelBlock,"//") 46 if pos <>0 then 47 RightBlock = Right(SelBlock, Len(SelBlock)-2) 48 ActiveDocument.Selection = RightBlock 49 End if 50 Next 51 End if 52 End if 53 End Sub
具体方法参照http://blog.163.com/fantasy_sunny/blog/static/195918212201222504855353/
感谢原作者辛苦贴图。
标签:des style blog http io color os sp for
原文地址:http://www.cnblogs.com/Daringoo/p/4105835.html