Join

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), Invalid procedure call or argument sourcearray has more than one dimension
13 (&HD), Type mismatch sourcearray is Null, or an element of it is an array
94 (&H5E), 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.

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