vb 去掉以“//”为注释行的内容

来源:互联网 发布:淘宝分享有礼有什么用 编辑:程序博客网 时间:2024/05/02 04:48
 
'//去掉源代码中的“//”注释语句Public Function cliearAnnotation(strCode As String) As String    Dim arr, a As Integer, strFront As String    arr = Split(strCode, vbCrLf)    For a = 0 To UBound(arr)        If InStr(arr(a), "//") Then            '//检测//前面是否有字符            strFront = Split(arr(a), "//")(0)            strFront = Replace(strFront, " ", "")            strFront = Replace(strFront, vbTab, "")            If Len(strFront) = 0 Then '如果//前没有字符                strCode = Replace(strCode, arr(a), "")            End If        End If    Next a    cliearAnnotation = strCode    '    VB.Clipboard.Clear'    VB.Clipboard.SetText cliearAnnotationEnd Function


只能去掉前面"//"前面的内容,

如//ssssss

不能去掉在代码未的内容

如:dim a as string //sssss这样保持不变

0 0
原创粉丝点击