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!

character count with read more... for message board 4

Status
Not open for further replies.

btween

Programmer
Aug 7, 2003
338
US
I am building a message board and want to have a page just listing the first line of each message followed by a read more link going to a detail page.

The data flows from anaccess database. how can I make my page only display the first say 60 characters of the message without displaying the whole message?

to display the whole message I would say:


<%=(rsMessage("description"))%>

thanks for your help
 
How about:

<%=(Left(rsMessage("description"), 60))%>

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Ah, I would extend that statement to include a length check vefore the Left call, otherwise your going to get nasty error statements if the statement somehow comes in under 60 characters,

-T

barcode_1.gif
 
Good thinking. As star for going above and beyond.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Well, a quicker cut to nearest spacelike Chris's method in the other post would be:
Code:
Function CutToSpace(origStr,maxChars)
   If Len(origStr) < maxChars Then
      CutToSpace = origStr
   Else
      CutToSpace = Left(yourString,InStrRev(yourString," ",maxChars)) & "..."
   End If
End Function

Not sure why i posted that, just felt like posting osmehitng, been a slow afternoon :p

barcode_1.gif
 
wow,

thanks for all the replies. I'm sure I can format this anyway I need to now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top