国产探花免费观看_亚洲丰满少妇自慰呻吟_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

菜鳥學堂:
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 元江| 东丰县| 宁津县| 额济纳旗| 盐山县| 江川县| 桑植县| 彰化县| 淄博市| 息烽县| 青海省| 宁陕县| 安丘市| 昌乐县| 特克斯县| 临猗县| 河东区| 平南县| 泰和县| 固镇县| 潮安县| 清水县| 云和县| 大冶市| 江陵县| 怀远县| 调兵山市| 宜兴市| 肇州县| 西城区| 大渡口区| 玉林市| 通辽市| 班戈县| 上栗县| 景泰县| 汾阳市| 桃源县| 浏阳市| 都昌县| 汉川市|