VBS tutorial: Functions – ltrim, rtrim and trim functions

Time:2021-10-25

Ltrim, rtrim, and trim functions

Return without leading spaces(LTrim). subsequent spaces(RTrim)Or leading and trailing spaces(Trim)A copy of the string.

LTrim(string)

RTrim(string)

Trim(string)

stringArgument is any valid string expression. IfstringIf the parameter contains null, theNull

explain

The following example usesLTrim, RTrim, andTrimThe function is used to remove the spaces at the beginning, at the end, and at the beginning and end of a string:

Dim myvarmyvar = ltrim ("VBScript") 'myvar contains "VBScript". Myvar = rtrim ("VBScript")'myvar contains "VBScript". Myvar = trim ("VBScript")'myvar contains "VBScript".