RTrim - VBScript


Overview

The RTrim command removes all trailing spaces from a string. It is commonly used to clean up user input, remove whitespace from the ends of file paths or URLs, and ensure consistent string formatting.

Syntax

RTrim(string) -> trimmed_string

Parameters:

  • string: The string to trim.

Options/Flags

None

Examples

WScript.Echo RTrim("VB Script  ")   ' Output: VB Script
WScript.Echo RTrim("/my/path/  ")    ' Output: /my/path/

Common Issues

  • Ensure the input string is a valid string. Using RTrim on non-string data types will result in an error.

Integration

RTrim can be used in conjunction with other commands, such as LTrim (removes leading spaces) and Trim (removes leading and trailing spaces), for advanced string manipulation tasks.

CleanedString = LTrim(RTrim(UserInput))   ' Removes leading and trailing spaces
  • LTrim
  • Trim
  • FormatNumber
  • FormatCurrency