打印

[asp] 标题长度问题,在线等[已解决]

biaoti=<%=rs("1")%><%=rs("2")%>
有师表字数过多,biaoti超过30个汉字的长度
如何截取 ,我只想在超过3030个汉字的长度的情况下对<%=rs("2")%>进行截取。

[ 本帖最后由 假鸟 于 2008-9-23 20:43 编辑 ]
<%=Left(rs(1) & rs(2), 30)%>

rs("1")和rs("2")是什么?字段名可以为 1或 2?  时间太长记不清了.好像不能数据开头的吧?
http://Reallydo.Com 承接ASP程序各种定做修改服务。
引用:
原帖由 playboy2925 于 2008-9-21 18:18 发表


rs("1")和rs("2")是什么?字段名可以为 1或 2?  时间太长记不清了.好像不能数据开头的吧?
你好,这个知识代替,不是问题的关键

TOP

up下

TOP

还在为头像烦恼?还在为不能关注好友动态烦忧?快来蓝色理想家园吧!

回复 4# 假鸟 [楼主] 的帖子

2#不是已经给出答案?
承接ASP定制,http://08-if.cn/

TOP

哦了,没注意不好意思,谢谢playboy2925

TOP

简单的:
'截取指定字符
Function lenStr(title,n)
       n=int(n/2)
       lenStr=left(title,n)
       if len(title)>n then lenStr=lenStr&".."
End Function
http://www.itsic.cn

TOP

复杂点的
'*************************************************
'函数名:gotTopic
'作  用:截字符串,汉字一个算两个字符,英文算一个字符
'参  数:str   ----原字符串
'       strlen ----截取长度
'返回值:截取后的字符串
'*************************************************
function gotTopic(str,strlen)
       if str="" then
              gotTopic=""
              exit function
       end if
       dim l,t,c, i
       str=replace(replace(replace(replace(str,"&nbsp;"," "),""",chr(34)),"&gt;",">"),"&lt;","<")
       l=len(str)
       t=0
       for i=1 to l
              c=Abs(Asc(Mid(str,i,1)))
              if c>255 then
                     t=t+2
              else
                     t=t+1
              end if
              if t>=strlen then
                     gotTopic=left(str,i) & "…"
                     exit for
              else
                     gotTopic=str
              end if
       next
       gotTopic=replace(replace(replace(replace(gotTopic," ","&nbsp;"),chr(34),"""),">","&gt;"),"<","&lt;")
end function
http://www.itsic.cn

TOP

不用那么麻烦吧!
<%
biaoti=rs("1")&rs("2")
if len(biaoti)>30 then
   biaoti=rs("1")&left(rs("2"),30-len(rs("1")))
end if
%>
简单点就行了,在asp中又不会出现中文乱码,如果不是特殊需要最好不要区分判断中英文,服务器性能很重要呀。

[ 本帖最后由 flashmayi 于 2008-9-23 17:56 编辑 ]

TOP