国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

left() 函數是 VBScript 的函數,VBScript 將1個漢字看作1個字符,因此用 l

2024-07-21 02:25:04
字體:
來源:轉載
供稿:網友
left() 函數是 vbscript 的函數,vbscript 將1個漢字看作1個字符,因此用 left()不能得到正確的字符長度。

我自己編寫了如下3個函數,用來取代 len()、left()、right(),希望能解決您的問題。

'--------------------------------------------------------
'name:        lenx
'argument:        ustr
'return:
'description:    返回字符串的長度,1個中文字符長度為2
'--------------------------------------------------------

function lenx(byval ustr)
    dim thelen,x,testustr
    thelen = 0

    for x = 1 to len(ustr)
        testustr = mid(ustr,x,1)
        if asc(testustr) < 0 then
            thelen = thelen + 2
        else
            thelen = thelen + 1
        end if
    next
    lenx = thelen
end function

'--------------------------------------------------------
'name:        leftx
'argument:        ustr        待處理的字符串
'        ulen        要截取的長度
'return:
'description:    返回指定長度的字符串,1個中文字符長度為2
'--------------------------------------------------------

function leftx(byval ustr,byval ulen)
    dim i,j,uteststr,thestr

    leftx = ""
    j = 0

    for i = 1 to len(ustr)
        uteststr= mid(ustr,i,1)
        thestr    = thestr & uteststr
        if asc(uteststr) < 0 then
            j = j + 2
        else
            j = j + 1
        end if
        if j >= ulen then exit for
    next
    leftx = thestr
end function

'--------------------------------------------------------
'name:        rightx
'argument:        ustr        待處理的字符串
'        ulen        要截取的長度
'return:
'description:    返回指定長度的字符串,1個中文字符長度為2
'--------------------------------------------------------

function rightx(byval ustr,byval ulen)
    dim i,j,uteststr

    rightx = ""
    j = 0

    for i = len(ustr) to 1 step -1
        uteststr = mid(ustr,i,1)
        rightx = rightx & uteststr
        if asc(uteststr) < 0 then
            j = j + 2
        else
            j = j + 1
        end if
        if j >= ulen then exit for
    next
end function

菜鳥學堂:
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 道孚县| 琼海市| 彭山县| 房山区| 邳州市| 湘潭市| 防城港市| 松溪县| 志丹县| 综艺| 青川县| 始兴县| 双流县| 南郑县| 万宁市| 安宁市| 昌宁县| 遂平县| 双鸭山市| 安乡县| 武城县| 昌图县| 高淳县| 阳信县| 临沧市| 敖汉旗| 诏安县| 衡山县| 华安县| 巴林左旗| 乐都县| 江都市| 囊谦县| 沾益县| 周宁县| 甘孜| 论坛| 淮安市| 汤阴县| 清苑县| 滨海县|