asp截取字符串的两种应用

时间:2009-08-19 17:11:00 

1、纯粹的截取字符串

function cutstr(thestr1,strlen) 
dim l,t,c 
l=len(thestr1) 
if l《1 then exit function 
t=0 
for dxy1=1 to l 
c=Abs(asc(Mid(thestr1,dxy1,1))) 
if c>255 then 
t=t+2 
else 
t=t+1 
end if 
if t>=strlen then 
thev=mid(thestr1,1,dxy1) 
exit for 
else 
thev=thestr1 
end if 
next 
cutstr=thev 
end function

2、截取字符串,不足用空格补上

function cutstr(thestr,strlen) 
dim l,t,c 
l=len(thestr) 
t=0 
for dxy=1 to l 
c=Abs(asc(Mid(thestr,dxy,1))) 
if c>255 then 
t=t+2 
else 
t=t+1 
end if 
if t>=strlen then 
thev=left(thestr,dxy) 
exit for 
else 
bu=strlen-t 
for bui=1 to bu 
strbu=" " 
strbuall=strbuall&strbu 
next 
thev=thestr&strbuall 
strbu="" 
strbuall="" 
end if 
next 
cutstr=thev 
end function


 

标签:字符串,函数
0
投稿

猜你喜欢

  • 提升网站可用性的3个忠告

    2008-01-31 13:48:00
  • ASP中正则表达式的应用

    2010-05-27 12:24:00
  • 如何在页面中对不同的数据进行相同的处理?

    2010-06-26 12:30:00
  • ASP sql:rs.open语句详细说明

    2008-03-17 11:30:00
  • 移动网站开发:标记语言

    2010-06-08 13:42:00
  • asp select下拉菜单选择图标并实时显示

    2011-04-03 10:33:00
  • 用ADODB.Stream代替FSO读取/写入文本文件

    2008-01-31 12:19:00
  • ASP怎样获得代码中第一张图片地址

    2008-10-29 09:40:00
  • MySQL Order By索引优化

    2011-01-04 19:56:00
  • 发一个数字拼图网页游戏

    2008-10-12 10:02:00
  • ASP读取MySQL数据库出现乱码的解决办法

    2010-03-08 14:25:00
  • SQL Server数据在不同数据库中的应用

    2008-12-24 15:34:00
  • 网页iframe元素应用浅析

    2009-04-11 18:11:00
  • 服务器XMLHTTP(Server XMLHTTP in ASP)基础

    2008-11-11 12:45:00
  • 灵活调用xsl来解析xml文档(js异步)

    2008-09-05 17:12:00
  • SQL Server中选出指定范围行的SQL语句写法

    2008-12-09 15:04:00
  • js实现单机双人象棋设计分析

    2008-05-20 12:57:00
  • CSS压缩:技巧与工具

    2009-12-11 18:26:00
  • 谈谈网页设计中的字体应用 (3) 实战应用篇·上

    2009-11-24 13:09:00
  • asp如何用WSH获取机器的IP配置信息?

    2010-06-13 14:39:00
  • asp之家 网络编程 m.aspxhome.com