Print Page | Close Window

limiting characters

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=11539
Printed Date: 30 March 2026 at 5:57am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: limiting characters
Posted By: ainsworth14
Subject: limiting characters
Date Posted: 15 August 2004 at 11:28am

hi there,

just curious to know if there is a way to display only a specific amount of characters in a description field on an asp page?

for example i have a description field in my DB but when displayed on my asp page i only want say 50 characters displayed (kinda like a brief description, but without having to create a new DB field for it).

i new to the development side and was just curious?

 

many thanks

mark




Replies:
Posted By: Mart
Date Posted: 15 August 2004 at 11:30am

Reponse.Write Left(Variable, 0, 50)

Left(string, startat, length)



Posted By: ainsworth14
Date Posted: 15 August 2004 at 11:54am

thanks for swift response

where would i place in this string?

<%=(rsResults.Fields.Item("Description").Value)%>

 

i have tried a few times but get errors?

thanks
mark



Posted By: ainsworth14
Date Posted: 15 August 2004 at 12:03pm

even better would be a word count, so not to cut off words half way through, is this possible?

 

 



Posted By: dj air
Date Posted: 15 August 2004 at 1:10pm

paste <%= Left(rsResults.Fields.Item("Description").Value),0,50) %>

where you want it displayied, after the connection is opened.

 

to stop at x words you could try the following

strDescTemp = rsResults.Fields.Item("Description").Value

saryDESC = split(strDescTemp," ")

intCounter = 1

do WHILE intCounter < Number of words

if not intCounter = 1 then strDesc = strDesc & "&nbsp;"
strDesc = strDesc & saryDESC(intCounter)

intCounter = intCounter +1

loop

you can try teh above code, please note that it hasn't been tested. if you get any errors please feel free to reply back.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net