网站制作学习网ASP→正文:DoTrimProperly
字体:

DoTrimProperly

ASP 2008/2/20 9:34:09  点击:不统计

这是个sub过程,取标题的前xx字,后面的用“...”表示

第一步:将以一代码加入到<html>前

<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>

function DoTrimProperly(str, nNamedFormat, properly, pointed, points)

dim strRet

strRet = Server.HTMLEncode(str)

strRet = replace(strRet, vbcrlf,"")

strRet = replace(strRet, vbtab,"")

If (LEN(strRet) > nNamedFormat) Then

strRet = LEFT(strRet, nNamedFormat)

If (properly = 1) Then

Dim TempArray

TempArray = split(strRet, " ")

Dim n

strRet = ""

for n = 0 to Ubound(TempArray) - 1

strRet = strRet & " " & TempArray(n)

next

End If

If (pointed = 1) Then

strRet = strRet & points

End If

End If

DoTrimProperly = strRet

End Function

</SCRIPT>





第二步:在需要显示的地方加入:



<% =(DoTrimProperly((rs("title")), 16, 0, 1, "...")) %>



·上一篇:asp时间之差 >>    ·下一篇:学习asp(1) >>
推荐文章
最新文章