Introduction
This is a String.Format
equivalent function for classic ASP.
Background
I am working on an old ASP classic application (fixing bugs etc.). Have to say, I still love traditional classic ASP.
It takes moments to do something that would normally take hours in .NET; plus, it always feels so much faster to execute =)
Anyway, I needed a function similar to String.Format
in C#. I could not find anything on Google, so I created my own and thought I would share.
Using the code
The code speaks for itself I think!
Function StringFormat(sVal, aArgs)
Dim i
For i=0 To UBound(aArgs)
sVal = Replace(sVal,"{" & CStr(i) & "}",aArgs(i))
Next
StringFormat = sVal
End Function
StringFormat("this {0} a tes{1} string containing {2} values", _
Array("is","t","some"))