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 strSplitNextItem(ByVal strBodyLine As String) As String
' Procedure :   strSplitNextItem
' Description:  Split the given declaration line at either a comma or a colon
' By:           Chris Greaves Inc.
' Inputs:       A comment-free line of a module.
' Returns:      STRING.
' Assumes:      The line compiles error-free.
' Side Effects: None.
' Tested:       by the calls shown below.
' Fails when a colon or comma appears in a string
    Dim intComma As Integer ' the position of the leading comma(,), if any
    Dim intColon As Integer ' the position of the leading colon(:), if any
    intComma = InStr(1, strBodyLine, ",")
    intColon = InStr(1, strBodyLine, ":")
    If intComma = 0 Then ' no comma was found, so
        If intColon = 0 Then ' no colon was found either, so
            strSplitNextItem = "" ' flush the line.
        Else
            strSplitNextItem = Right$(strBodyLine, Len(strBodyLine) - intColon + 1)
        End If
    Else
        If intColon = 0 Then ' a comma but no colon was found so
            strSplitNextItem = Right$(strBodyLine, Len(strBodyLine) - intComma + 1)
        Else ' both a comma and a colon were found; which comes first?
            If intColon < intComma Then
                strSplitNextItem = Right$(strBodyLine, Len(strBodyLine) - intColon + 1)
            Else
                strSplitNextItem = Right$(strBodyLine, Len(strBodyLine) - intComma + 1)
            End If
        End If
    End If
'Sub TESTstrSplitNextItem()
'Dim strLine As String
'strLine = "Dim strAr() As String, strBr, strCR(): dim lng1, lng2"
'    While strLine <> ""
'        strLine = strSplitNextItem(strLine)
'        strLine = Trim(Right$(strLine, Len(strLine) - 1))
'    Wend
'End Sub
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 strSplitNextItem(ByVal strBodyLine As String) As String
' Procedure :   strSplitNextItem
' Description:  Split the given declaration line at either a comma or a colon
' By:           Chris Greaves Inc.
' Inputs:       A comment-free line of a module.
' Returns:      STRING.
' Assumes:      The line compiles error-free.
' Side Effects: None.
' Tested:       by the calls shown below.
' Fails when a colon or comma appears in a string
    Dim intComma As Integer ' the position of the leading comma(,), if any
    Dim intColon As Integer ' the position of the leading colon(:), if any
    intComma = InStr(1, strBodyLine, ",")
    intColon = InStr(1, strBodyLine, ":")
    If intComma = 0 Then ' no comma was found, so
        If intColon = 0 Then ' no colon was found either, so
            strSplitNextItem = "" ' flush the line.
        Else
            strSplitNextItem = Right$(strBodyLine, Len(strBodyLine) - intColon + 1)
        End If
    Else
        If intColon = 0 Then ' a comma but no colon was found so
            strSplitNextItem = Right$(strBodyLine, Len(strBodyLine) - intComma + 1)
        Else ' both a comma and a colon were found; which comes first?
            If intColon < intComma Then
                strSplitNextItem = Right$(strBodyLine, Len(strBodyLine) - intColon + 1)
            Else
                strSplitNextItem = Right$(strBodyLine, Len(strBodyLine) - intComma + 1)
            End If
        End If
    End If
'Sub TESTstrSplitNextItem()
'Dim strLine As String
'strLine = "Dim strAr() As String, strBr, strCR(): dim lng1, lng2"
'    While strLine <> ""
'        strLine = strSplitNextItem(strLine)
'        strLine = Trim(Right$(strLine, Len(strLine) - 1))
'    Wend
'End Sub
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