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 strNext(strNow As String, strSet As String)
' Procedure :   strNext
' Description:  Generate the next available string in sequence.
'               Typical use - obtaining a unique module or file name.
' Copyright: Chris Greaves Inc.
' Inputs:       String representing our latest effort
'               String of characters from which to generate a new name
' Returns:      A string, length will be zero if we failed.
' Assumes:      Nothing
' Side Effects: None
' Tested:       By the calls shown below.
'
' If we are at the end of the set, we have failed, else deliver the next sequential character.
    Dim intPos As Integer
    intPos = InStr(1, strSet, Right(strNow, 1))
    If intPos = 0 Then
        strNext = strNow & Left(strSet, 1)
    Else
        If intPos = Len(strSet) Then
            strNext = ""
        Else
            strNext = Left(strNow, Len(strNow) - 1) & Mid(strSet, intPos + 1, 1)
        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 strNext(strNow As String, strSet As String)
' Procedure :   strNext
' Description:  Generate the next available string in sequence.
'               Typical use - obtaining a unique module or file name.
' Copyright: Chris Greaves Inc.
' Inputs:       String representing our latest effort
'               String of characters from which to generate a new name
' Returns:      A string, length will be zero if we failed.
' Assumes:      Nothing
' Side Effects: None
' Tested:       By the calls shown below.
'
' If we are at the end of the set, we have failed, else deliver the next sequential character.
    Dim intPos As Integer
    intPos = InStr(1, strSet, Right(strNow, 1))
    If intPos = 0 Then
        strNext = strNow & Left(strSet, 1)
    Else
        If intPos = Len(strSet) Then
            strNext = ""
        Else
            strNext = Left(strNow, Len(strNow) - 1) & Mid(strSet, intPos + 1, 1)
        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