|
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 strGenerateTag(strContainer As String, strIn As String, strAlphabet As String) As String
' Procedure : strGenerateTag
' Description: Return a string unique in the current repository.
' Copyright: Chris Greaves Inc.
' Inputs: The current repository of strings.
' The base string, possibly not unique.
' An alphabet for use as suffices.
' Returns: A unique string
' Assumes: None.
' Side Effects: None.
' Tested: By the calls shown below.
Dim strFirstTag As String
Dim strSet As String
If InStr(1, strContainer, strIn) > 0 Then
strSet = strAlphabet
strFirstTag = strIn & Left(strSet, 1)
While (InStr(strContainer, strFirstTag) > 0) And (strSet <> "")
strSet = Right(strSet, Len(strSet) - 1)
strFirstTag = strIn & Left(strSet, 1)
Wend
If strSet = "" Then
' MsgBox " need a new loop"
strSet = strAlphabet
strFirstTag = strGenerateTag(strContainer, strIn & Left(strSet, 1), strAlphabet)
While (InStr(strContainer, strFirstTag) > 0) And (strSet <> "")
strSet = Right(strSet, Len(strSet) - 1)
strFirstTag = strGenerateTag(strContainer, strIn & Left(strSet, 1), strAlphabet)
Wend
End If
strGenerateTag = strFirstTag
Else
strGenerateTag = strIn
End If
'Sub TESTstrGenerateTag()
'Dim strTest As String
'Dim intI As Integer
'strTest = "alpha beta gamma"
'For intI = 1 To 9
' strTest = strTest & " " & strGenerateTag(strTest, "alpha", "xy")
' MsgBox strTest
'Next intI
'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 |