Name
Trim Function
Syntax
Trim(string
)
-
string
Use: Required
Data Subtype: String
Any string expression.
Return Value
A Variant of subtype String.
Description
Removes both leading and trailing spaces from a given string.
Rules at a Glance
If string is Null
, the Trim
function returns Null
.
Programming Tips & 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.
See Also
LTrim Function, RTrim Function |
Get VBScript in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.