VBA - Join Function


Advertisements

A Function, which returns a string that contains a specified number of substrings in an array. This is an exact opposite function of Split Method.

Syntax

Join(List[,delimiter]) 

Parameter Description

  • List − A required parameter. An array that contains the substrings that are to be joined.

  • Delimiter − An optional parameter. The character, which used as a delimiter while returning the string. The default delimiter is Space.

Example

Add a button and add the following function.

Private Sub Constant_demo_Click()
   ' Join using spaces
   a = array("Red","Blue","Yellow")
   b = join(a)
   msgbox("The value of b " & " is :"  & b)
  
   ' Join using $
   b = join(a,"$")
   msgbox("The Join result after using delimiter is : " & b)
End Sub

When you execute the above function, it produces the following output.

The value of b is :Red Blue Yellow
The Join result after using delimiter is : Red$Blue$Yellow
vba_arrays.htm
Advertisements