Monday, September 10, 2007

How to display only a set number of words from a paragraph with asp?

Here is the simple code to display a set number of words from a long paragraph...

Dim shortdesc, index, strText
strText = "How to display only a set number of words from a paragraph with asp. How to display only a set number of words from a paragraph with asp. How to display only a set number of words from a paragraph with asp. "

strText=Replace(strText," "," ")

for index =1 to len(strText)
if mid(strText,index,1)= " " then
words = words+1
end if

if words=24 then
shortdesc = left(strText,index)
end if

next
Response.write shortdesc

No comments: