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 strGenerateNewFilename(strMyPath As String, strMyName As String, strMyExtent As String, strMyLag As String) As String
' Procedure :   strBumpUpName
' Description:  Generate the next string in the sequence
' Copyright: Chris Greaves Inc.
' Inputs:       Generic string, pool of available characters.
' Returns:      String, generic name augmented by a character.
' Assumes:      Nothing
' Side Effects: The pool will be reduced by one character.
' Tested:       By the calls shown below.
    Dim strMn As String
    strMn = strMyName
    While boolFileExists(strMyPath + strMn + strMyExtent) And strMyLag <> ""
        strMn = strBumpUpName(strMn, strMyLag)
    Wend
    If boolFileExists(strMyPath + strMn + strMyExtent) Then
        strGenerateNewFilename = ""
    Else
        strGenerateNewFilename = strMyPath + strMn + strMyExtent
    End If
'Sub TESTstrBumpUpName()
'    Dim strGeneric As String
'    strGeneric = "alpha"
'    Dim strPool As String
'    strPool = "ghj"
'    MsgBox strBumpUpName(strGeneric, strPool) & " : " & strGeneric & " : " & strPool
'    MsgBox strBumpUpName(strGeneric, strPool) & " : " & strGeneric & " : " & strPool
'    MsgBox strBumpUpName(strGeneric, strPool) & " : " & strGeneric & " : " & strPool
'    MsgBox strBumpUpName(strGeneric, strPool) & " : " & strGeneric & " : " & strPool
'End Sub
' Sub TESTstrGenerateNewFilename()
'    Dim strP As String
'    Dim strF As String
'    Dim strE As String
'    Dim strJ As String
'    strP = "c:\temp\"
'    strF = "eraseme"
'    strE = ".txt"
'    strJ = strGenerateNewFilename(strP, strF, strE, "abc")
'    If strJ = "" Then
'        MsgBox "couldn't make new name from original"
'    Else
'        Dim intFile
'        intFile = FreeFile
'        Open strJ For Output As intFile
'        Print #intFile, "eraseme"
'        Close intFile
'    End If
'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 strGenerateNewFilename(strMyPath As String, strMyName As String, strMyExtent As String, strMyLag As String) As String
' Procedure :   strBumpUpName
' Description:  Generate the next string in the sequence
' Copyright: Chris Greaves Inc.
' Inputs:       Generic string, pool of available characters.
' Returns:      String, generic name augmented by a character.
' Assumes:      Nothing
' Side Effects: The pool will be reduced by one character.
' Tested:       By the calls shown below.
    Dim strMn As String
    strMn = strMyName
    While boolFileExists(strMyPath + strMn + strMyExtent) And strMyLag <> ""
        strMn = strBumpUpName(strMn, strMyLag)
    Wend
    If boolFileExists(strMyPath + strMn + strMyExtent) Then
        strGenerateNewFilename = ""
    Else
        strGenerateNewFilename = strMyPath + strMn + strMyExtent
    End If
'Sub TESTstrBumpUpName()
'    Dim strGeneric As String
'    strGeneric = "alpha"
'    Dim strPool As String
'    strPool = "ghj"
'    MsgBox strBumpUpName(strGeneric, strPool) & " : " & strGeneric & " : " & strPool
'    MsgBox strBumpUpName(strGeneric, strPool) & " : " & strGeneric & " : " & strPool
'    MsgBox strBumpUpName(strGeneric, strPool) & " : " & strGeneric & " : " & strPool
'    MsgBox strBumpUpName(strGeneric, strPool) & " : " & strGeneric & " : " & strPool
'End Sub
' Sub TESTstrGenerateNewFilename()
'    Dim strP As String
'    Dim strF As String
'    Dim strE As String
'    Dim strJ As String
'    strP = "c:\temp\"
'    strF = "eraseme"
'    strE = ".txt"
'    strJ = strGenerateNewFilename(strP, strF, strE, "abc")
'    If strJ = "" Then
'        MsgBox "couldn't make new name from original"
'    Else
'        Dim intFile
'        intFile = FreeFile
'        Open strJ For Output As intFile
'        Print #intFile, "eraseme"
'        Close intFile
'    End If
'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