各位怎样才能把的输出长度控制啊

zhp258 2005-05-28 10:32:19
各位怎样才能把<%=rs6("zhuti")%>的输出长度控制啊
...全文
111 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
up1002 2005-05-28
  • 打赏
  • 举报
回复
给你一个好东西吧。

function cstrlength(str)
temp_str=len(str)
cstrlength=0
for i=1 to temp_str
test_str=(mid(str,i,1))
if asc(test_str)>0 then
cstrlength=cstrlength+1
else
cstrlength=cstrlength+2
end if
next
end function

function cstrleft(str,l)
temp_str=len(str)
for i=1 to temp_str
test_str=(mid(str,i,1))
cstrleft=cstrleft&test_str
if asc(test_str)>0 then
lens=lens+1
else
lens=lens+2
end if
if lens>=l then exit for
next
end function

上面两个函数分别是统计一个字符串实际字节数的函数和截取一个字符串左侧字节数的函数。
(一个汉字占两个字节; 显示上,一个汉字也相当于两个西文字符的宽度)

如此:

<%
if cstrlength(rs6("zhuti"))>xxx then
response.write cstrleft(rs6("zhuti"),xxx)
else
response.write rs6("zhuti")
end if
%>
sun94510451 2005-05-28
  • 打赏
  • 举报
回复
<%=mid(rs6("zhuti"),1,t)%>
t:你想要的长度。
jekexys2004 2005-05-28
  • 打赏
  • 举报
回复
你怎样控制??
zhp258 2005-05-28
  • 打赏
  • 举报
回复
colinliu 2005-05-28
  • 打赏
  • 举报
回复
<%=left(rs6("zhuti"),10)%>
colinliu 2005-05-28
  • 打赏
  • 举报
回复
<%=right(rs6("zhuti"),10)%>

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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