注册 | 登录 | 设为首页 | 加入收藏
您当前的位置:飞翔学院-IT中国 → 编程开发Asp → 文章内容

这是我写的函数,很好用的

作者:IT 来源:不详 发布时间:2007-9-2 0:33:00
'*************测字符串长度**************

Function CheckStringLength(txt)
    txt=trim(txt)
    x = len(txt)
    y = 0
    for ii = 1 to x
        if asc(mid(txt,ii,1)) < 0 or asc(mid(txt,ii,1)) >255 then    '如果是汉字
            y = y + 2
        else
            y = y + 1
        end if
    next
    CheckStringLength = y

End Function

'*************  截取字符串  **************

function InterceptString(txt,length)
    txt=trim(txt)
    x = len(txt)
    y = 0
    if x >= 1 then
        for ii = 1 to x
            if asc(mid(txt,ii,1)) < 0 or asc(mid(txt,ii,1)) >255 then    '如果是汉字
                y = y + 2
            else
                y = y + 1
            end if
            if y >= length then         
                txt = left(trim(txt),ii)    '字符串限长
                exit for
            end if
        next
        InterceptString = txt
    else
        InterceptString = ""
    end if

End Function

http://www.itcnw.com/
  • 打印文档
  • 推荐好友
  • 返回顶部
  • 增大字体
  • 减少字体
关于本站 | 工作机会 | 合作网站 | 广告服务 | 市场合作| 联系我们 | 抽奖活动
版权所有: 武汉威俊科技有限公司 Copyright 2005-2007 www.ITCNW.COM All rights reserved