ConcatenateStrings_AmongString

Collect strings matching search from a longer string.
I used it to concatenate all 'Styles=' statements from several HTML tags with parent-child-grandchild relationships.
Says it needs IIF, but IIF is already built-in VBA, because in case you need it in ASP Classic, you need to have IIF as separate function.
Will return these as ANString, a list of strings separated by Sepa that you can define when you call it.
You might also need to deal with cleaning after return, like removing double-quotes.

CodeFunctionName
What is this?

Public

Tested

Original Work
Function ConcatenateStrings_AmongString(sInLarge, sFromString, sToString, Optional Sepa = "|")
    ' Conncatenate all strings inside sInLarge, istarting from sFromString, ending in sToString
    '        ConcatenateStrings_AmongString()
    ' This will turn this string (passed sInLarge variable) ....
    '        <tr style="full style1" > <td < style="full style2" > <span style="full style3;font-size:40px;" >Some things just do add up until you do the math </span > </td > </tr >
    ' Into this ...
    '        "full style1|"fullstyle2|"full style3
    '
    '    Needs VBInst(), IIF(), CutString()
    Rett = ""
    StartConcat = 1
GetNext:
    Location1 = VBInstr(sFromString, sInLarge, StartConcat)
    If Location1 = 0 Then GoTo ByeBye
    Rett = Rett & IIf(Rett = "", "", Sepa) & CutString(sInLarge, sFromString, sToString, StartConcat)
    StartConcat = Location1 + 1
    GoTo GetNext
ByeBye:
    ConcatenateStrings_AmongString = Rett
End Function

sInLarge, sFromString, sToString, Optional Sepa = "|"

Views 180

Downloads 64

CodeID
DB ID