当前位置: 首页 > 图文教程 > 网络编程 > ASP > [原创]asp截取字符串的两种应用

ASP
asp取动态表单中数据并写入xml文件,用xsl显示
一个非常简单的将半角转换为中文的函数
Jmail发邮件的例子
ASP常用的几个功能模块
改进性能和样式的 24个 ASP 技巧
给blog加上运行代码功能
关于静态页生成问题 突破form数量限制
UTF-8编码
utf-8编码转换成gb2312
Utf-8和Gb2312乱码问题的终结
UTF-8转GB2312函数
防止网站内容被小偷采集的ASP代码
ASP中过滤UBB和Html标签
在线数据库管理工具(db007) v1.5
Response.Flush的使用心得
域名查询系统用到的类
检测函数 asp class
利用ASP规划聊天室
聊天室实现私聊
多域名绑定到一个空间访问不同首页的技巧

ASP 中的 [原创]asp截取字符串的两种应用


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 37 ::
收藏到网摘: n/a

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