Visual Basic (VB and VBA)

Copyright 1999-2001 Christopher Greaves. All rights reserved.
Home Page and email to [email protected]
If in doubt, record a macro and inspect the entrails!

 

 

Please read the DISCLAIMER.

Here is an INDEX to all the procedures.

You will probably need one copy of my GLOBAL DECLARATIONS.



Public Function szStripLineOfComments(ByVal szLine As String) As String
    Dim iCounter As Integer
    Dim vaSingleQuotePositions As Variant
    ''' Get an array of all the positions of Chr$(39)
    vaSingleQuotePositions = vaGetOccurencesOfStringInString(szLine, Chr$(39))
    ''' If is Null, then goto EndFunction
    If Not IsNull(vaSingleQuotePositions) Then
        ''' The assumption in VBA is,if there is a single quote, it MUST be wrapped
        ''' within double quotes (assuming no line continuations), else is demarkating the start of a comment
        ''' The first ' without a " to the right of it in the string is a comment.
        For iCounter = LBound(vaSingleQuotePositions) To UBound(vaSingleQuotePositions)
            If Not CBool(InStr(1, Right$(szLine, Len(szLine) - CLng(vaSingleQuotePositions(iCounter))), Chr$(34))) Then
                szLine = Trim$(Left$(szLine, CLng(vaSingleQuotePositions(iCounter)) - 1))
                Exit For
            End If
        Next iCounter
    End If
    szStripLineOfComments = szLine
End Function

We all knew nothing when we started …
Home Page and Contact Information
Send email to [email protected].
This page was last updated Thursday, November 15, 2001

 

 

Hosted by www.Geocities.ws

1

Visual Basic (VB and VBA)

Copyright 1999-2001 Christopher Greaves. All rights reserved.
Home Page and email to [email protected]
If in doubt, record a macro and inspect the entrails!

 

 

Please read the DISCLAIMER.

Here is an INDEX to all the procedures.

You will probably need one copy of my GLOBAL DECLARATIONS.

Public Function szStripLineOfComments(ByVal szLine As String) As String
    Dim iCounter As Integer
    Dim vaSingleQuotePositions As Variant
    ''' Get an array of all the positions of Chr$(39)
    vaSingleQuotePositions = vaGetOccurencesOfStringInString(szLine, Chr$(39))
    ''' If is Null, then goto EndFunction
    If Not IsNull(vaSingleQuotePositions) Then
        ''' The assumption in VBA is,if there is a single quote, it MUST be wrapped
        ''' within double quotes (assuming no line continuations), else is demarkating the start of a comment
        ''' The first ' without a " to the right of it in the string is a comment.
        For iCounter = LBound(vaSingleQuotePositions) To UBound(vaSingleQuotePositions)
            If Not CBool(InStr(1, Right$(szLine, Len(szLine) - CLng(vaSingleQuotePositions(iCounter))), Chr$(34))) Then
                szLine = Trim$(Left$(szLine, CLng(vaSingleQuotePositions(iCounter)) - 1))
                Exit For
            End If
        Next iCounter
    End If
    szStripLineOfComments = szLine
End Function

We all knew nothing when we started …
Home Page and Contact Information
Send email to [email protected].
This page was last updated Thursday, November 15, 2001

 

 

Hosted by www.Geocities.ws

1