Sub String Extras Class

StripVBCommentsSample

Signature (Visual Basic / VBA)

Private Sub StripVBCommentsSample()
    ' Print some samples of the StripVBComments function.

    Dim fKeepFlags As Integer
    For fKeepFlags = True To False
        Debug.Print
        Debug.Print "fKeepFlags: " & fKeepFlags
        Debug.Print StripVBComments("    ' This is a comment-only line.", fKeepFlags)
        Debug.Print StripVBComments("    ' This line contains a copyright notice.", fKeepFlags)
        Debug.Print StripVBComments("    'Note: This line represents a flag.", fKeepFlags)
        Debug.Print StripVBComments("    Beep: Beep: Beep ' Beep three times.", fKeepFlags)
        Debug.Print StripVBComments("    BeepStr = ""This is a 'string literal.'""", fKeepFlags)
        Debug.Print StripVBComments("    BeepStr = ""This is a 'string literal.'"" ' ... followed by a comment.", fKeepFlags)
        Debug.Print StripVBComments("    BeepStr = ""This is a """"'string literal'"""" with embedded quotes.", fKeepFlags)
    Next fKeepFlags
End Sub