954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

count words or characters in strings advice needed

My looped output looks like this

Link 1, Link2 , link3 , link 4 .....and so on

I need a way to count the RS in either words or chars to cut it if needed in this manner:
Link1, Link2, Li .....

Have tied to measure the length with Len() but might a counter instead to sum the actual posts together and then replace those with a cutted string... or something like that

And the posts comes out of a loop so there is not possible to just take one RS("post") and
cut that one, I need the total length of string.

Any advices how to do that

TobbeK
Junior Poster
190 posts since Feb 2008
Reputation Points: 10
Solved Threads: 3
 

To complete my question...

This is a static input-output where a number of words are counted, and then cutted in view.

<%
Input = "Link1 Link2 Link3 Link4 Link5"
Input = Trim(Input)

Do While InStr(1, Input, " ")
Input = Replace(Input, " ", " ")
Loop

Words = Split(Input, " ")
Response.Write ("Full string with: " & UBound(Words) + 1 & " words: " & Input)
Response.Write("
")
Output = Left(Input,15) & " ..."
Response.Write("Cutted string with " & UBound(Words) +1 & " words: " & Output)
%>

The prints looks like this:

Full string with: 5 words: Link1 Link2 Link3 Link4 Link5
Cutted string with 5 words: Link1 Link2 Lin ...

TobbeK
Junior Poster
190 posts since Feb 2008
Reputation Points: 10
Solved Threads: 3
 

This works well on static strings, but I could not make it run properly in a loop with RS posts

<%
Str = "Link1 & Link2 Link3 Link & Link5 "
Response.Write(CutStr(Str,10))
Function CutStr(Str, sLength)
If Len (Str) > sLength Then
CutStr = Left(Str,sLength) & "...."
Else
CutStr = Str
End If
End Function
Str = Left(Str,4)
Response.Write(Str)
%>
TobbeK
Junior Poster
190 posts since Feb 2008
Reputation Points: 10
Solved Threads: 3
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You