MathInsideANString

Perform math on numbers inside list of numbers in format of ANString.
Something like 8|9|3|
Uses Evaluate
Return a string after performing math calculations on each of the items in ANString
ANString example 344|559|8990
MathEq example * 45
Sepa example |
Return
15480|25155|404550
Because we did the math as                    344 * 45|559 * 45|8990 * 45

CodeFunctionName
What is this?

Public

Tested

Original Work
Function MathInsideANString(ANString, MathEq, Optional Sepa = "|")
    ' Return a string after performing math calculations on each of the items in ANString
    ' ANString example 344|559|8990
    ' MathEq example * 45
    ' Sepa example |
    ' Return
    ' 15480|25155|404550
    ' Because we did the math as                    344 * 45|559 * 45|8990 * 45
    '
    Rett = ANString
    Rett2 = ""
    For Each MeQ In Split(ANString, Sepa)
        If Rett > "" Then Rett2 = Rett2 & Sepa
        Rett2 = Rett2 & Evaluate(MeQ & MathEq)
    Next
    If Rett2 > "" Then Rett = Rett2
    MathInsideANString = Rett
End Function

ANString, MathEq, Optional Sepa = "|"

MathInsideANString("8|9|3", " * 14", "|")
to Return
112|126|42

Views 112

Downloads 72

CodeID
DB ID