急,关于一个数据库字段的显示问题?

sea76 2004-03-24 04:52:53
我想显示数据库中一个字段下内容的前十五个汉字,多于的用省略号代替,这段程序怎样写?谢谢!
...全文
60 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
jasonboy 2004-03-24
  • 打赏
  • 举报
回复
对啊,关键是判断中英文
zhuomaocn 2004-03-24
  • 打赏
  • 举报
回复
public function GetByteCount(data)
dim bcnt , n , nCODE
bcnt = 0

For n = 1 To Len(data)
nCODE = Asc(Mid(data, n, 1))
If nCODE >= 0 And nCODE <= 255 Then
bcnt = bcnt + 1
Else
bcnt = bcnt + 2
End If
Next
GetByteCount = bcnt
End Function
考虑的一般的英数和汉字混合的情况,你说的15个汉字,意思就是取前面30个字节长字符串。
if GetByteCount(strContent) > 30 then
for i= 1 to 30
strTemp = Left(strContent,i)
if GetByteCount(strTemp) >= 30 then
strTemp = strTemp & "....."
exit for
end if
next
end if

strTemp 就是你要的值

潜水的鱼 2004-03-24
  • 打赏
  • 举报
回复
龙辉的答案就是你想要的吧!
51windows 2004-03-24
  • 打赏
  • 举报
回复
<table width="200" border="1">
<tr>
<td width="80"><div style="width:80px;overflow: hidden;text-overflow:ellipsis">
<nobr>我是一个兵,来自老百姓</nobr></div></td>
<td> </td>
<td> </td>
</tr>
</table>
---------------
注意 text-overflow:ellipsis 在IE6以下无效
dyzh 2004-03-24
  • 打赏
  • 举报
回复
a=left(rs("abc"),30)
a=a&"..."
多少个省略号?不可能剩下的都是用省略号代替吧??如果要全部用的话就用len()算出长度
angelheavens 2004-03-24
  • 打赏
  • 举报
回复
<%
If Len(Content)<15 Then
Response.Write(Content)
Else
Response.Write(Left(Content,15)&"...")
End If
'还要判断英文等字符
'http://expert.csdn.net/Expert/TopicView1.asp?id=2870545
%>
dyzh 2004-03-24
  • 打赏
  • 举报
回复
a=left(rs("abc"),30)
a=a&"..."
多少个省略号?不可能剩下的都是用省略号代替吧??如果要全部用的话就用len()算出长度
7teeth 2004-03-24
  • 打赏
  • 举报
回复
leftb(xxxx,15)&"......"

28,390

社区成员

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

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