Link to home
Start Free TrialLog in
Avatar of nickleplated
nickleplated

asked on

Trim Words Function

I'd like to show the first 25 words from a text field variable.

ie: Return a paragraph but only show the first 25 words.

Avatar of Gary
Gary
Flag of Ireland image

<%
oldstring="lots of different words upto 25 words"
tempstring=split(oldstring," ")
for count=0 to 24
newstring=newstring & " " & tempstring(count)
next
response.write newstring
%>
ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you can try:

<%
    value = "abcdefghijklmnopqrstuvwxyz"
    Left(value, 25)
%>
for a fuller version:

After Submit of your text value:
<%
   Dim value
   ' "txtField" depends on what is your text type name
   value = Request.form("txtField")

   Response.write Left(value,25)
%>

or you can also use this in the client code

<script language="vbscript">
Sub OnLoad
   Dim value
   value = "abcdefghijklmnopqrstuvwxyz"
   MsgBox Left(value,25)
End Sub
</script>
Hope it helps! :p
Avatar of nickleplated
nickleplated

ASKER

Very nice Gary, once again: Cheers.

Sorry San_Gal, but I needed 25 words not 25 characters.
oops... sorry... didnt read that carefully! :p

At least you got your help! :)