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 strAllNext(strNow As String, strSet As String, intLen As Integer)
' Procedure :   strAllNext
' Description:  Generate all possible available strings in sequence.
'               Typical use - obtaining a unique module or file name.
' Copyright: Chris Greaves Inc.
' Inputs:       String representing our basic effort
'               String of characters from which to generate a new name
'               Maximum allowable length of our string
' Returns:      A string, length will be zero if we failed.
' Assumes:      Nothing
' Side Effects: None
' Tested:       By the calls shown below.
' July 19th 1999: This does generate all combinations, but it repeats some.
' I am too presssed to worry about it right now.
'
' For each character in the set, deliver the next sequential character.
Dim strTemp As String
Dim intI As Integer
    strTemp = strNow
    While strTemp <> "" And boolAllNext(strTemp)
        MsgBox strTemp
        strTemp = strNext(strTemp, strSet)
    Wend
' Nothing doing at the basic level. We need to recurse iteratively through higher levels
    For intI = 1 To Len(strSet) ' here we start a new essay for each character in our set
'       We will have as many iterations as there are chacters in the set
'       Each iteration will look like the one that spawned this one,
'       Except that the starting string will be one character longer than the original.
        strTemp = strNow & Mid(strSet, intI, 1) ' generate our new starter
        While Len(strTemp) <= intLen And strTemp <> "" And boolAllNext(strTemp)
            MsgBox strTemp
            strTemp = strAllNext(strTemp, strSet, intLen)
        Wend
    Next intI
'Sub TESTlngstrAllNext()
'MsgBox strAllNext("Mine", "abc", 6) ' Normal use
'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 strAllNext(strNow As String, strSet As String, intLen As Integer)
' Procedure :   strAllNext
' Description:  Generate all possible available strings in sequence.
'               Typical use - obtaining a unique module or file name.
' Copyright: Chris Greaves Inc.
' Inputs:       String representing our basic effort
'               String of characters from which to generate a new name
'               Maximum allowable length of our string
' Returns:      A string, length will be zero if we failed.
' Assumes:      Nothing
' Side Effects: None
' Tested:       By the calls shown below.
' July 19th 1999: This does generate all combinations, but it repeats some.
' I am too presssed to worry about it right now.
'
' For each character in the set, deliver the next sequential character.
Dim strTemp As String
Dim intI As Integer
    strTemp = strNow
    While strTemp <> "" And boolAllNext(strTemp)
        MsgBox strTemp
        strTemp = strNext(strTemp, strSet)
    Wend
' Nothing doing at the basic level. We need to recurse iteratively through higher levels
    For intI = 1 To Len(strSet) ' here we start a new essay for each character in our set
'       We will have as many iterations as there are chacters in the set
'       Each iteration will look like the one that spawned this one,
'       Except that the starting string will be one character longer than the original.
        strTemp = strNow & Mid(strSet, intI, 1) ' generate our new starter
        While Len(strTemp) <= intLen And strTemp <> "" And boolAllNext(strTemp)
            MsgBox strTemp
            strTemp = strAllNext(strTemp, strSet, intLen)
        Wend
    Next intI
'Sub TESTlngstrAllNext()
'MsgBox strAllNext("Mine", "abc", 6) ' Normal use
'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