WelcomeServicesPortfolioKnowledge BaseContact Us
27 Seconds, Inc.


Knowledge base View Article

need hosting?

Need hosting? We use and love our host - CrystalTech.com!
Need hosting? We use and love our host - CrystalTech.com!

Text Disguise - CAPTCHA-image/Human Interactive Proof web services

National Holiday Dates and Bank Holiday Dates - web site that provides the dates of national and bank holidays for the United States, United Kingdom, Ireland and Scotland

Holiday Web Service - web services for programmers to provide the dates of national and bank holidays in their applications for the United States, United Kingdom, Ireland and Scotland

Our Family Heart - web site to help families communicate no matter where they are

What?! You haven't heard about the greatest remote controlled flyer to come out in years?! Checkout the FlyTech DragonFly now!

Pad strings to a specific length

Summary: When generating text-based e-mails, there is the need to display data in a "table" format. To do this, you must pad the strings with space so that they are a specific length. To do that, use a simple function like this one.
 
Keywords: EMAIL
FITSPACE
PAD
SPACE
STRING
TABLE
Applicable Software: Active Server Pages (ASP)
 
Body:

When generating text-based e-mails, there is the need to display data in a "table" format. To do this, you must pad the strings with space so that they are a specific length. To do that, use a simple function like this one.

Function FitSpace(str, max)

Dim out
	If Len(str) > max Then
		out = Left(str, max - 3) & "..."
	Else
		out = str
	End If

	If max > Len(str) Then
		out = str & Space(max - Len(str))
	End If

	FitSpace = out

End Function

To use it, you would do:

Dim s
	s = "This is 30 characters234567890XXXXX"
	s = FitSpace(s, 30)

	Response.Write chr(34) & s & Chr(34)

 
Author: Douglas L. Setzer, II, http://www.27seconds.com
Posted On: 9/8/2003 1:03:31 PM

Rate this article: Average: n/a
n/a12345678910
Comments?

Article Search   |   All Articles

 

 
©2002 27 Seconds, Inc. All Rights Reserved.