手机
当前位置:查字典教程网 >编程开发 >ASP教程 >asp实现截取字符串函数
asp实现截取字符串函数
摘要:如果标题过长,因为页面布局的限制,只能列表10个字符,这个函数会帮你实现的复制代码代码如下:'截取字符串strvalue(标题,字数)fun...

如果标题过长,因为页面布局的限制,只能列表10个字符,这个函数会帮你实现的

复制代码 代码如下:

'截取字符串 strvalue(标题,字数)

function strvalue(str,lennum)

dim p_num

dim i

if strlen(str)<=lennum then

strvalue=str

else

p_num=0

x=0

do while not p_num > lennum-2

x=x+1

if asc(mid(str,x,1))<0 then

p_num=int(p_num) + 2

else

p_num=int(p_num) + 1

end if

strvalue=left(trim(str),x)&"…"

loop

end if

end function

function strlen(str)

dim page_len

page_len=0

strlen=0

if trim(str)<>"" then

page_len=len(trim(str))

for xx=1 to page_len

if asc(mid(str,xx,1))<0 then

strlen=int(strlen) + 2

else

strlen=int(strlen) + 1

end if

next

end if

end function

使用方法:

复制代码 代码如下:

<%=strvalue("准确的编程语言,可正确对代码语法着色,输入简单几个字的代码片段说明",10)%>

以上所述就是本文的全部内容了,希望大家能够喜欢。

【asp实现截取字符串函数】相关文章:

asp中的Rnd 函数

asp实现树型结构

asp写入记录

asp 字符串连接数据库方法

asp 常用的字符串处理函数

获取字符中中文首字字符

判断字符串中相同字符的个数

用asp实现检测文件编码

asp最常用的分页函数

asp实现批量录入数据的实现

精品推荐
分类导航