# Join
{: .no_toc }

Returns a string created by joining a number of substrings contained in an array.

Syntax: **Join(** *sourcearray* [ **,** *delimiter* ] **)**

*sourcearray*
: *required* One-dimensional array containing substrings to be joined.

*delimiter*
: *optional* String character used to separate the substrings in the returned string. If omitted, the space character (`" "`) is used. If *delimiter* is a zero-length string (`""`), all items in the list are concatenated with no delimiters.

> [!NOTE]
> twinBASIC also takes a *sourcearray* whose elements are of a type other than **String** or **Variant**, such as **Long** or **Double**. For a **Long** array VB6 and 64-bit VBA raise error 5, *Invalid procedure call or argument*.

### Common Errors

| Error | When |
|---|---|
| [5 (`&H5`)](/Reference/Run-time-Errors.md#5), *Invalid procedure call or argument* | *sourcearray* has more than one dimension |
| [13 (`&HD`)](/Reference/Run-time-Errors.md#13), *Type mismatch* | *sourcearray* is **Null**, or an element of it is an array |
| [94 (`&H5E`)](/Reference/Run-time-Errors.md#94), *Invalid use of Null* | *delimiter* is **Null**, or an element of *sourcearray* is **Null** |

### Example

This example uses **Join** to concatenate an array of strings with a delimiter.

```tb check_build
Debug.Print Join(Array("one", "two", "three"), ", ")    ' "one, two, three"
Debug.Print Join(Array("a", "b", "c"), "-")             ' "a-b-c"
Debug.Print Join(Array("x", "y"), "")                   ' "xy"
```

### See Also

- [Filter](/tB/Modules/Strings/Filter.md), [Split](/tB/Modules/Strings/Split.md) functions
