大家帮我改一下代码

radiumwong 2007-05-25 07:51:59
功能是做一个排行榜,如果标题长度大于10就取子串,后面加…
我写的这个怎么去不准阿,而且都加…

<%
dim str
str=len(rs("softName"))
if str>10 then
response.Write left(rs("softName"),10)&"…"
else response.Write rs("softName")
end if
%>

谢谢各位啦
...全文
332 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
knowledge_Is_Life 2008-05-01
  • 打赏
  • 举报
回复
关注 接分
snlixing 2007-06-02
  • 打赏
  • 举报
回复
<%if len(trim(rs("softName")))>10 then response.write left(rs("softName"),10)&"……"
else
response.write rs("softName")
end if
lovebaby 2007-06-02
  • 打赏
  • 举报
回复
我也来一个:

'**************************************************
'函数名: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," "," "),""",chr(34)),">",">"),"<","<")
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," "," "),chr(34),"""),">",">"),"<","<")
end function
Mapleleaf123 2007-05-28
  • 打赏
  • 举报
回复
Function InterceptString(txt,length)
dim x,ii,y
txt=trim(txt)
x = len(txt)
y = 0
if x >= 1 then
for ii = 1 to x
if asc(mid(txt,ii,1)) < 0 or asc(mid(txt,ii,1)) >255 then
y = y + 2
else
y = y + 1
end if
if y >= length then
txt = left(trim(txt),ii)&"..."
exit for
end if
next
InterceptString = txt
else
InterceptString = ""
end if
End Function
waitxing 2007-05-28
  • 打赏
  • 举报
回复
str=len(rs("softName"))
----------------------
在这一句下面加上这句
response.write str
看看取的值是否正确。
Jinglecat 2007-05-25
  • 打赏
  • 举报
回复
跟踪一下看看~

4,008

社区成员

发帖
与我相关
我的任务
社区描述
它是一种微软环境下的轻量级的解释型语言,它使用COM组件、WMI、WSH、ADSI访问系统中的元素,对系统进行管理。
社区管理员
  • vbScript社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧