删除VB代码中所有注释的方法
如题,删除VB代码中所有注释的方法(源代码),只针对当前活动模块或窗体或工作表(ExcelVBA中)。考虑:单撇('),双撇('') 及 Rem
在网上找到一段,不知道该怎么修改(代码中的红色字体)。
'此代码由“正则测试工具v1.1.35”自动生成,请直接调用TestReg过程
Private Sub TestReg()
Dim s As String
Dim reg As Object
s = "s = ""ssss,'xxxxxxx',ffff"" 'xxxxxxx'''''bbbbb _" & vbCrLf & _
" xxxxxxxffffff" & vbCrLf & _
"'adfadfadfadfad _" & vbCrLf & _
"adfadfadfadfadfadf _" & vbCrLf & _
"adfadfasdfadfadfadfa" & vbCrLf
Set reg = CreateObject("vbscript.regExp")
reg.Global = True
reg.IgnoreCase = True
reg.MultiLine = True
reg.Pattern = "'([^""\r\n]+?_\r\n)+"
s = reg.Replace(s, "'")
reg.Pattern = "'[^""\r\n]+(\r\n)"
s = reg.Replace(s, "$1")
Debug.Print s
End Sub
补充:VB , 基础类