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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display string upton a certain character 1

Status
Not open for further replies.

tyutghf

Technical User
Apr 12, 2008
258
GB
I have an overview page and a description page. The overview page displays only the first 500 characters using

left(rs("description"),500)

but this is cutting the text off in awkward places. So I wanted to use something such as <break> in the text. On the overview page, the string is output UNTIL it reaches the <break> command then it stops.

Is that sort of thing possible?
 
Use the InStr() function to find the position of the string "<break>", and then the Mid() function to extract the text you are looking for.

Another idea is to only break on a word, not a part of a word, like below:
Code:
Dim arrDesc, sDescription, sWord
sDescription = ""

arrDesc = Split(rs("description"), " ")
For Each sWord In arrDesc
   If Len(sDescription & " " & sWord) > 500 Then
      Exit For
   Else
      sDescription = sDescription & " " & sWord
   End If
Next

 
Thanks guitarzan, I went for the instr option as it lets us break the text in varying places depending on the text. Works really well, although I have bookmarked you code to break on a word for the future :eek:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top