O'Reilly logo

VBScript in a Nutshell, 2nd Edition by Ron Petrusha, Matt Childs, Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Trim Function

Syntax

Trim(string)
string

Use: Required

Data Type: String

Any string expression.

Return Value

A String.

Description

Returns a string in which any leading and trailing spaces in an original string are removed.

Rules at a Glance

If string is Null, the Trim function returns Null.

Programming Tips and Gotchas

Trim combines into a single function call what would otherwise be separate calls to the RTrim and LTrim functions.

VBA/VBScript Differences

VBA includes a Trim$ function that returns the a trimmed string rather than a trimmed string variant. Because VBScript does not support strong typing, the function is not implemented in VBScript.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required