dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: ASP
Expertise: Intermediate
May 28, 2003

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Word-wrap ASP Output on Long Strings with No Blanks

If you need to output to the screen or print a long text string that has no spaces, the text string will not wrap to the preset dimensions of a table or to the browser window frame.

This simple function will wrap the text string based on any setting you provide:


<%
Function WordWrap(OrigString)

StrLength = Len(OrigString)

intPosition = 1

StrWrapNumber = 80

StrLoop = StrLength\ StrWrapNumber

If StrLoop > 0 then
For LoopStep = 0 to StrLoop
	WrapString = Mid(OrigString, intPosition, StrWrapNumber)
	Response.Write WrapString
	Response.Write "<br>"
	intPosition = intPosition + StrWrapNumber
Next
Else
	Response.Write OrigString
End if

End Function
%>
You can change the length of the block in the line

StrWrapNumber = 80
You can use this function as an include page and call it like so:

<%
dim f_ OverallGoal
f_OverallGoal = Result1("OverallGoal")
response.write WordWrap(f_OverallGoal)
%>
Note: This example applies to re-displaying from a database query; for re-displaying a form before submittal just use Request.Form rather than Result1, etc.
Steve Skelton
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date