The parameter of the join function is an array and a separator (Optional). It imports all elements of the array to a string. The elements are separated by separators and the string is returned. For example Code Returns the following strings: 1, 2, 3, 4, 5. Dim Testarr ( 0 To 4 ) As Variant
Testarr ( 0 ) = 1
Testarr ( 1 ) = 2
Testarr ( 2 ) = 3
Testarr ( 3 ) = 4
Testarr ( 4 ) = 5
Debug. Print Join (Testarr, " , " ))
The parameter of the split function is a string, a separator (optional), the number of returned substrings, and a comparison method. This function returns a zero-based array with a substring as an array element. The following code uses the string generated in the preceding example as the parameter of the split function. The split function restores an array. Dim Strtest As String
Dim Testarr As Variant
Strtest = " 1, 2, 3, 4, 5 "
Testarr = Split (Strtest, " , " )
Dim I As Integer
For I = 0 To Ubound (Testarr)
Print Testarr (I)
Next
The join and split functions are very useful when you need to convert the array content to a string and restore the array from the string. For example, convert the width of each column of the table to a string and save it to the Registry. Then, restore the column width from the registry. Using these two functions simplifies the storage and processing of array content.