Sven Axelsson, on the above site, has a version of Uwe's original, called "FormatMessage-like formatting in VBScript" which looks almost exactly like that below (except he calls his "Fmt", rather than "Subst").
function Subst(str, args)
dim res
dim i
res = str
for i = 0 to UBound(args)
res = Replace(res, "%" & CStr(i+1) & "%" , args(i) )
next
res = Replace(res, "\n", vbCrLf)
res = Replace(res, "\t", vbTab)
Subst = res
end function
And an example of use:
theSelector = "SELECT * FROM %1% WHERE [aKey] >= (DATESERIAL(%2%, %3%, %4% ) + TIMESERIAL( %5%, 0, 0 )) AND [aKey] <= (DATESERIAL(%2%, %3%, %4% ) + TIMESERIAL( %5%, 59, 59 ))" theSelect = Subst( theSelector, Array( theTable, theYear, theMonth, theDay, theHour ) )
No comments:
Post a Comment