function fmt helps you to format a in VBScript as you do in C.
In C, you write:
prf( \"this is %s number %d\", \"test\", 1 );
then you would use the function fmt in VBScript like this:
dim str
str = fmt( \"this is %x number %x\", Array(\"test\", 1) )
Details
The complete function looks like this:
´ works like the prf-function in C.
´ takes a with format characters and an .gif' />
´ to expand.
´
´ the format characters are always \"%x\", independ of the
´ type.
´
´ usage example:
´ dim str
´ str = fmt( \"hello, Mr. %x, today´s date is %x.\", Array(\"Miller\",Date) )
´ response.Write str
function fmt( str, args )
dim res ´ the result .
res = \"\"
dim pos ´ the current position in the args .gif' />.
pos = 0
dim i
for i = 1 to Len(str)
´ found a fmt char.
Mid(str,i,1)=\"%\" then
i<Len(str) then
´ normal percent.
Mid(str,i+1,1)=\"%\" then
res = res & \"%\"
i = i + 1
´ expand from .gif' />.
Mid(str,i+1,1)=\"x\" then
res = res & CStr(args(pos))
pos = pos+1
i = i + 1
end
end
´ found a normal char.
res = res & Mid(str,i,1)
end
next
fmt = res
end function
The format character is always %x, independent of the actual type, since VBScript has no direct types like eger or .
最新评论