杨的空间
业精于勤,荒于嬉,行成于思,毁于随
function getStrLength(strTemp)'用於求中英文字符串的长度
    strTemp=replace(strTemp,""","""")
    dim DBCS
    DBCS = (len("中文")=2)  '双字节字符集(DBCS)
    if DBCS then
        strlen=len(strTemp)
        trueLen=strlen
        dim i
        for i=1 to strlen
            c=asc(mid(strTemp,i,1))
            if c<0 or c>255 then
                trueLen=trueLen+1
            end if
        next
        getStrLength=Cint(trueLen/2)
    else
        getStrLength=len(strTemp)
    end if
end function

function convert_to_fit_lenght(titleTemp,lenTemp)
    dim l
    l=1.0
    dim ch
    returnlength=1
    do while Abs(Int(-l))<lenTemp and returnlength<=len(titleTemp)
        ch=mid(titleTemp,returnlength,1)
        if asc(ch) < 0 or asc(ch) > 255 then
            l=l+1
        else
            l=l+0.5
        end if
        returnlength=returnlength+1
    loop
    convert_to_fit_lenght = returnlength
end function

function myLeft(titleTemp,lenTemp)
    myLeft = Left(titleTemp,convert_to_fit_lenght(titleTemp,lenTemp))
end function
posted on 2007-03-03 17:26 阅读(338) 评论(0)  编辑 收藏 引用 所属分类: 技术类
只有注册用户登录后才能发表评论。