一次就好口琴简谱c调:如何设置ASP的标题显示的数目?

来源:百度文库 编辑:高校问答 时间:2024/04/29 04:57:11
document.write("<%
tsql="select top "&topicnum&" id,userid,topicinfo,bd,edittime,totable from topic where type<>3

and bd not in(select id from bdinfo where type=3 or type=4) order by edittime desc"
set topnew=conn.execute(tsql)
i=0
do while not topnew.eof
topicinfo=topnew("topicinfo")
topicinfo=split(topicinfo,"|")
i=i+1
response.write"<li><a target=_blank title="&kbbs(topicinfo(1))&" href="&bbsurl&"/showbbs.asp?

bd="&topnew("bd")&"&id="&topnew("id")&"&totable="&topnew("totable")&">"&lefttrue(kbbs

(topicinfo(1)),13)&"</a></li>"
topnew.movenext
if i=topicnum then exit do
loop
topnew.close
set topnew=nothing
%>");

我把标题长度设为了13个字符,但是现在是一个中文算两个字符的,我想把他改为一个中文也只算一个字符,应该怎么修改上面的代码呢?
唉。。。算了。。。把这一块的字体搞成宋体的,好排版就行了。

给你一个函数类,使用方法与len一样
示范:GetTopIc("中国防大学",4)
显示为:中国

function GetTopIc(ByVal str,ByVal strlen)
if str="" or isnull(str)then
gettopic=""
exit function
end if
dim l,t,c, i,strTemp
str=replace(replace(replace(replace(str," "," "),""",chr(34)),">",">"),"<","<")
l=len(str)
t=0
strTemp=str
strlen=Clng(strLen)
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
strTemp=left(str,i)
exit for
end if
next
if strTemp<>str then
strTemp=strTemp
end if
getTopic=replace(replace(replace(replace(strTemp," "," "),chr(34),"""),">",">"),"<","<")
end function

我说一句 VBS语言的字符串 不论英文还是中文字 都只算一个字符的