Visual Basic Language Reference  

Join Function

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

Function Join(
   ByVal SourceArray() As { Object | String },
   Optional ByVal Delimiter As String = " "
) As String

Parameters

SourceArray()
Required. One-dimensional array containing substrings to be joined.
Delimiter
Optional. String 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.

Exceptions/Errors

Exception type Error number Condition
ArgumentException 5 SourceArray() is not one dimensional.

Example

The following example demonstrates use of the Join function.

Dim myItem(2) As String
Dim myShoppingList As String
myItem(0) = "Pickle"
myItem(1) = "Pineapple"
myItem(2) = "Papaya"
' Returns "Pickle, Pineapple, Papaya"
myShoppingList = Join(myItem, ", ")

See Also

Split Function | ArgumentException