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 strGetSub(ByVal str As String, ByVal intPos As Integer, strDelim As String) As String
' Procedure :   strGetSub
' Description:  Return a substring of a string
' Copyright: Chris Greaves Inc.
' Inputs:       A string.
'               A positional counter
'               A string delimiter
' Returns:      The substring bounded by the intPos'th occurence of strDelim
' Assumes:      Nothing
' Side Effects: None.
' Tested:       By the calls shown below.
' From the given "str", return the "intPos"th substring delimited by "strDelim"
    strGetSub = "" ' default or any error returns a zero-length string
    If intPos < 1 Or intPos > Len(str) Then
        strGetSub = "" ' default or any error returns a zero-length string
    Else
        str = strDelim & str & strDelim
        Dim intP As Integer ' pointer to loop along the string
        intP = 1
        While (intPos > 1) And (intP > 0)
            intP = InStr(intP + 1, str, strDelim)
            intPos = intPos - 1
        Wend
        If intP > 0 Then
            If InStr(intP + 1, str, strDelim) > 0 Then
                strGetSub = Mid(str, intP + 1, InStr(intP + 1, str, strDelim) - intP - 1)
            End If
        End If
    End If
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 strGetSub(ByVal str As String, ByVal intPos As Integer, strDelim As String) As String
' Procedure :   strGetSub
' Description:  Return a substring of a string
' Copyright: Chris Greaves Inc.
' Inputs:       A string.
'               A positional counter
'               A string delimiter
' Returns:      The substring bounded by the intPos'th occurence of strDelim
' Assumes:      Nothing
' Side Effects: None.
' Tested:       By the calls shown below.
' From the given "str", return the "intPos"th substring delimited by "strDelim"
    strGetSub = "" ' default or any error returns a zero-length string
    If intPos < 1 Or intPos > Len(str) Then
        strGetSub = "" ' default or any error returns a zero-length string
    Else
        str = strDelim & str & strDelim
        Dim intP As Integer ' pointer to loop along the string
        intP = 1
        While (intPos > 1) And (intP > 0)
            intP = InStr(intP + 1, str, strDelim)
            intPos = intPos - 1
        Wend
        If intP > 0 Then
            If InStr(intP + 1, str, strDelim) > 0 Then
                strGetSub = Mid(str, intP + 1, InStr(intP + 1, str, strDelim) - intP - 1)
            End If
        End If
    End If
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