Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Showing partial return

Status
Not open for further replies.

Bamarama

Programmer
Dec 29, 2006
49
US
I have tried to search for help, but since I am unsure as to what it is called, I am unable to get the right answer.

I am creating my own blog. I have everything working the way I want it to with posts and responses. The only thing I am unable to do is this.

When the thread is returned from the DB, it is usually lengthly. I want it to display say, the first 100 words, then end that with something like "...." and have a link show "Click to read more" (or something like that), where it would either open up a page with the whole story, or use some jscript and just show it on the same page.

Can someone point me in the right direction by giving me an example or telling me what this is called so I can search for it? I fell on the word "concatenation" and I think that may be it, but have yet to find what I need.

ANy help would be appreciated.

Bam
 
You could start here

If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Ok, thx for that link.

Just I just have to find about creating the link and the ... thanks again
 
WOrks well thanks a bunch.

Do you think in doing what I am doing, it would be better to count words instead? And is this possible?

I just think it would be better, so it doesn't break up a word.
 
You can use either method and still not break in the middle of a word.

To go by words, "split" the text by a space, which will give you an array, each element of which is a word. Then scroll through as many words as you want, appending to a new variable.

To go by characters, use the InStr function, which returns the position of the first string match. There is an optional first parameter that tells it what character to start the search at, so InStr(100,MyText," ") would find the first space after the 100th character.

Code:
Function ReturnFirstWords(strText, iNumWords)
   Dim arrText
   arrText = Split(arrText, " ")

   If iNumWords >= UBound(arrText) + 1 Then
      ReturnFirstWords = strText
   Else
      For x = 0 To iNumWords - 1
         ReturnFirstWords = ReturnFirstWords & arrText(x) & " "
      Next
   End If
End Function

Function ReturnFirstChars(strText, iNumChars)
   Dim iPosition

   If Len(strText) < iNumChars Then
      ReturnFirstChars = iNumChars
   Else
      iPosition = InStr(iNumChars, strText, " ")
      ReturnFirstChars = Left(strText, iPosition)
   End If
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top