• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 類似于C語言的printf函數

    發表于:2007-05-25來源:作者:點擊數: 標簽:類似于printfFunctionThe函數
    The function fmt helps you to format a string in VB Script as you do in C. In C, if you write: printf( "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

    The function fmt helps you to format a string in VBScript as you do in C.

    In C, if you write:

    printf( "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 printf-function in C.
    ' takes a string with format characters and an array
    ' 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 string.
        res = ""

        dim pos        ' the current position in the args array.
        pos = 0

        dim i
        for i = 1 to Len(str)
            ' found a fmt char.
            if Mid(str,i,1)="%" then
                if i<Len(str) then
                    ' normal percent.
                    if Mid(str,i+1,1)="%" then
                        res = res & "%"
                        i = i + 1

                    ' expand from array.
                    elseif Mid(str,i+1,1)="x" then
                        res = res & CStr(args(pos))
                        pos = pos+1
                        i = i + 1
                    end if
                end if

            ' found a normal char.
            else
                res = res & Mid(str,i,1)
            end if
        next

        fmt = res
    end function
    The format character is always %x, independent of the actual type, since VBScript has no direct types like integer or string.

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>