首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

ASP怎么截短字串

2012-02-05 
ASP如何截短字串ASP如何截短字串对中文当一个字符,英文和半角当半个字符,谢谢了。[解决办法] %Function My

ASP如何截短字串
ASP如何截短字串对中文当一个字符,英文和半角当半个字符,谢谢了。

[解决办法]
<%
Function Mylen2(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
Mylen2= txt
else
Mylen2= " "
end if
End Function

a= "在这里发贴,表示您接受了CSDN社区的 用户行为准则。 "
response.write mylen2(a,15)
%>

热点排行