Codefixer - ASP tutorials, resources and software
asp.netPRO “Best ASP.NET Host” – DiscountASP.NET
Home   Articles   Resources   ASP directory   ASP Tutorials   Code Snippets   ASP Applications   Forum
Saturday 17 May
MembersPro PayPal - ASP Membership software

ASP.NET 3.5 Hosting – DiscountASP.NET


ASP Partner ASP Partner ASP Partner more partners...

Trim, LTrim and RTrim VBScript functions

You can use the Trim function to remove spaces on both the left and the right side of a string.

syntax: Trim(string)

Example 1:

<%
myString=" This is an example using the Trim function.    "
Response.write Trim(myString)
%>

Output:

This is an example using the Trim function.

The LTrim function will remove spaces on the Left and the RTrim function will remove spaces on the right.
Imagine you created an online form with a textfield called 'txtName' and the visitor accidentally hit the space bar before filling in his name. The Request.form("txtName") command would retrieve his name with an accidental space before his name, so it can be good practice to use the Trim function for this eventuality as the example below shows.

<%
varName=Trim(Request.Form("txtName"))
%>

Other useful VBScript functions for Parsing String

LinksPro - Directory  and Link  Management Software




ASP.NET 3.5/2.0 Web Hosting: 3 Months FREE – Click Here!




About | Contact | Advertise | Feedback | Hire Us | Link

Site developed by Michael Wall - Web Design Belfast N.Ireland.
Copyright © 2000-2008. All rights reserved.

Do you intend to move to ASP.NET or have you already?
Yes will do
Have done
ASP does fine
Not a priority


Directory Software