jasonsalas
IS-IT--Management
Hi everyone,
I've been playing with a string which is built from calls to DB fields. In this example, the variable "trimmed" is a bit of text that can be imported from a form field or from a database field.
<%
trimmed = Replace(Trim(Left(objRSPortables("ProductDescription",165)),"'","’",1,-1,vbTextCompare)
If Len(trimmed) < 165 Then
Description.Write(trimmed)
Else
Description.Write(trimmed & "... (more)"
End If
%>
My problem is that mostly all of the time, the "ProductDescription" field will be larger than 165 characters, so the script appends the "... (more)" after the string. This more often than not winds up with ugly truncated strings that cutoff in the middle of words such as:
<!--
As the island’s Carabao population continues to grow on U.S. Navy property in Fena - a population that has caused many a problem to the ecosystem there - the Navy al... (more)
-->
Is there a way I can have the script kill off any additional characters (hopefully in blocks, so I could do it by whole words), so the strings can be a bit more presentable?
Thanks!
I've been playing with a string which is built from calls to DB fields. In this example, the variable "trimmed" is a bit of text that can be imported from a form field or from a database field.
<%
trimmed = Replace(Trim(Left(objRSPortables("ProductDescription",165)),"'","’",1,-1,vbTextCompare)
If Len(trimmed) < 165 Then
Description.Write(trimmed)
Else
Description.Write(trimmed & "... (more)"
End If
%>
My problem is that mostly all of the time, the "ProductDescription" field will be larger than 165 characters, so the script appends the "... (more)" after the string. This more often than not winds up with ugly truncated strings that cutoff in the middle of words such as:
<!--
As the island’s Carabao population continues to grow on U.S. Navy property in Fena - a population that has caused many a problem to the ecosystem there - the Navy al... (more)
-->
Is there a way I can have the script kill off any additional characters (hopefully in blocks, so I could do it by whole words), so the strings can be a bit more presentable?
Thanks!