欢迎光临
我们一直在努力

两个控制显示格式的函数(自动换行、自动省略)-ASP教程,脚本编码

建站超值云服务器,限时71元/月

1)函数:rowscode()—–每行显示n个字母,自动换行

function rowscode(str,n)

if len(str)<=n/2 then

rowscode=str

else

dim tstr

dim l,t,c

dim i

l=len(str)

tstr=""

t=0

for i=1 to l

c=asc(mid(str,i,1))

if c<0 then c=c+65536

if c>255 then

t=t+2

else

t=t+1

end if

tstr=tstr&(mid(str,i,1))

if t>n then

tstr=tstr&"<br>"

t=0

end if

next

rowscode= tstr

end if

end function

2)函数:lefttrue()—–如果字符串str的长度大于n,则显示左边的n个字符

function lefttrue(str,n)

if len(str)<=n/2 then

lefttrue=str

else

dim tstr

dim l,t,c

dim i

l=len(str)

tstr=""

t=0

for i=1 to l

c=asc(mid(str,i,1))

if c<0 then c=c+65536

if c>255 then

t=t+2

else

t=t+1

end if

if t>n then exit for

tstr=tstr&(mid(str,i,1))

next

lefttrue = tstr & "…"

end if

end function

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 两个控制显示格式的函数(自动换行、自动省略)-ASP教程,脚本编码
分享到: 更多 (0)

相关推荐

  • 暂无文章