目录
引出
VC++开发积累——如何在vc++6.0中进行多行代码批量注释和取消注释,宏文件的使用
多行注释的实现
新建一个宏文件,Macro文件
输入代码
'------------------------------------------------------------------------------
'FILE DESCRIPTION: 批量注释和取消批量注释
'------------------------------------------------------------------------------
Sub SetSelNote()'Sun DESCRIPTION: 过程SetSelNote 用于将选中的文本转换为注释
dim CurWin '当前获得的窗口
set CurWin = ActiveWindow
if CurWin.type<>"Text" Then '判断当前窗口是否是文本窗口
MsgBox "当前窗口不是代码窗口"
else
NoteType = "//"
BeginLine = ActiveDocument.Selection.TopLine
EndLine = ActiveDocument.Selection.BottomLine
if EndLine < BeginLine then
Line = BeginLine
BeginLine = EndLine
EndLine = Line
else
for row = BeginLine To EndLine
ActiveDocument.Selection.GoToLine row
ActiveDocument.Selection.SelectLine '选中当前行
ActiveDocument.Selection = NoteType + ActiveDocument.Selection
Next
End if
End if
End Sub
Sub CancelSelNote()
dim CurWin '当前获得的窗口
set CurWin = ActiveWindow
if CurWin.type<>"Text" Then '判断当前窗口是否是文本窗口
MsgBox "当前窗口不是代码窗口"
else
BeginLine = ActiveDocument.Selection.TopLine
EndLine = ActiveDocument.Selection.BottomLine
if EndLine < BeginLine then
Line = BeginLine
BeginLine = EndLine
EndLine = Line
else
for row = BeginLine To EndLine
ActiveDocument.Selection.GoToLine row
ActiveDocument.Selection.SelectLine'选中当前行
SelBlock = ActiveDocument.Selection
Trim(SelBlock)
pos = instr(SelBlock,"//")
if pos <>0 then
RightBlock