# Trim
{: .no_toc }

Returns a **String** containing a copy of a specified string without leading and trailing spaces.

Syntax: **Trim$(** *string* **)**, **Trim(** *string* **)**

*string*
: *required* Any valid string expression. If *string* contains **Null**, **Null** is returned.

The `$`-suffixed form returns a **String**; the unsuffixed form returns a **Variant** (**String**).

### Common Errors

| Error | When |
|---|---|
| [94 (`&H5E`)](/Reference/Run-time-Errors.md#94), *Invalid use of Null* | **Trim$** is given a *string* that is **Null** |

### Example

This example uses the **Trim** function to strip both leading and trailing spaces from a string variable.

```tb check_build
Dim MyString, TrimString
MyString = "  <-Trim->  "        ' Initialize string.
TrimString = Trim(MyString)      ' TrimString = "<-Trim->".
```

### See Also

- [LTrim](/tB/Modules/Strings/LTrim.md), [RTrim](/tB/Modules/Strings/RTrim.md) functions
