JOIN(sourcearray [,delimiter])

Returns a text string containing all the elements in an array (String).


sourcearrayThe array of strings (String).
delimiter(Optional) The text string to use as a separator (String).

REMARKS
* After you have finished processing an array that has been split you can use this function to concatenate the elements of an array back to a string concatenation.
* The "sourcearray" must be a 1-dimensional array.
* The "sourcearray" can be zero-based or one-based ?
* If "delimiter" is left blank, then the space character (" ") is used.
* If "delimiter" = "" (zero length string) then all the items are concatenated with no separator character.
* Doesn't work when the array is declared as "Date" data type (eg Dim vaArray(5) As Date).
* Does work when the array is declared as "Variant" data type (eg Dim vaArray(5) As Variant).
* This function cannot be used with fixed length arrays. You will see the following compile-time error: 'Can not assign or coerce array of fixed-length string or user defined type to Variant'.
* You can use the ARRAY function to return an array containing given values.
* You can use the FILTER function to return an array containing a subset of a string array based on a filter condition.
* You can use the SPLIT function to return an array containing a specified number of substrings.
* The equivalent .NET function is Microsoft.VisualBasic.Strings.Join
* For the Microsoft documentation refer to learn.microsoft.com

Dim vaArray() As String 
vaArray(0) = "string1"
vaArray(1) = "string2"
vaArray(2) = "string3"

Debug.Print Join(vaArray) '= "string1 string2 string3"
Debug.Print Join(vaArray," ") '= "string1 string2 string3"
Debug.Print Join(vaArray, "<>") '= "string1<>string2<>string3"
Debug.Print Join(vaArray, "") '= "string1string2string3"

© 2023 Better Solutions Limited. All Rights Reserved. © 2023 Better Solutions Limited Top