Welcome to my ASP Code Website

Trim ASP String Function

Trim is a commonly used ASP function that allows you to quickly remove any extra spaces at the beginning or ending of a string. It takes in one parameter:

* The string variable to operate on

The original string variable is not altered.

This is pretty much a required thing to do to ANY field a user types in for you to use. Users are notorious for putting extra spaces at the beginning or end of their input.

Let's say your user puts in their name and you take this in as UserName. But say the user has poor typing skills and you now get:

UserName = " Lisa Shea "

with extra spaces. You would use

UserName = Trim(UserName)

To turn that into just "Lisa Shea" with no spaces. Note that it leaves any spaces WITHIN the string - between the Lisa and the Shea. It only removes extra spaces at the beginning or end.

Still stuck? Please be sure to Contact Lisa Shea - that's me - and I'm happy to lend a hand. I've been programming in ASP classic for many, many years and can help you get through your coding challenge quickly and easily!

To have an easy to use, easy to read reference on hand as you code, also check out my Intro to ASP Book which comes in both ebook and paperback format.

Thanks for stopping in to my page - and good luck!

ASP String Functions