如何控制显示内容只显示前20个字符
3个回答
展开全部
'给你个函数,是自己写的。xstring是输入的字符,xnum是输出的字符
'2个ASCII=汉字
Function WordsLimit( xstring, xnum)
length = Len(xstring)
If (length > xnum) Then
top = xnum
tail = "…"
xx = 1
Do While (xx <= xnum)
If (Asc(Mid(xstring, xx, 1)) > 0) Then
If (xx + 1 <= length) Then
If (Asc(Mid(xstring, xx + 1, 1)) > 0) Then
xnum = xnum + 1
xx = xx + 1
End If
Else
tail = ""
Exit Do
End If
End If
If (xnum >= length) Then
tail = ""
Exit Do
End If
'If (xx > (top + yy)) Then Exit Do
xx = xx + 1
Loop
xstring = Mid(xstring, 1, xnum) & tail
End If
WordsLimit = xstring
End Function
'例:<%=WordLimit(rs(content),20)%>
'2个ASCII=汉字
Function WordsLimit( xstring, xnum)
length = Len(xstring)
If (length > xnum) Then
top = xnum
tail = "…"
xx = 1
Do While (xx <= xnum)
If (Asc(Mid(xstring, xx, 1)) > 0) Then
If (xx + 1 <= length) Then
If (Asc(Mid(xstring, xx + 1, 1)) > 0) Then
xnum = xnum + 1
xx = xx + 1
End If
Else
tail = ""
Exit Do
End If
End If
If (xnum >= length) Then
tail = ""
Exit Do
End If
'If (xx > (top + yy)) Then Exit Do
xx = xx + 1
Loop
xstring = Mid(xstring, 1, xnum) & tail
End If
WordsLimit = xstring
End Function
'例:<%=WordLimit(rs(content),20)%>
展开全部
function LeftStr(str,num)
if isnull(str) then
leftstr = ""
exit function
end if
str=trim(str)
if len(str)>num then
leftstr=left(str,num)+"..."
else
leftstr=str
end if
end function
if isnull(str) then
leftstr = ""
exit function
end if
str=trim(str)
if len(str)>num then
leftstr=left(str,num)+"..."
else
leftstr=str
end if
end function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<%=left(rs(content),20)%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询