Friday, September 9, 2011

VBScript Join

VBScript Join
VBScript Join function joins substrings (elements) of an array into one long string with each substring separated by the delimiter string.

Syntax of VBScript Join
Join(list[,delimiter])

list in one dimensional array that contains the substrings to be joined.

delimiter is the character(s) used to separate substrings in the returned strings.

Example 1 of VBScript Join
Dim a
Dim Arr(10)
Arr(0) = "This"
Arr(1) = "is"
Arr(2) = "Join"
Arr(3) = "Test!"
a=Join(Arr)
msgbox(a) 'Shows "This is Join Test!"

Example 2 of VBScript Join
Dim a
Dim Arr(3)
Arr(0) = "This"
Arr(1) = "is"
Arr(2) = "Join"
Arr(3) = "Test!"
a=Join(Arr, ",")
msgbox(a) 'Shows "This,is,Join,Test!"

Example 3 of VBScript Join
Dim a
Dim Arr(3)
Arr(0) = "This"
Arr(1) = "is"
Arr(2) = "Join"
Arr(3) = "Test!"
a=Join(Arr, "*")
msgbox(a) 'Shows "This*is*Join*Test!"

Example 4 of VBScript Join
Dim a
Months=Array("Jan","Feb","Mar","Apr","May","Jun","Jul")
a=Join(Months)
msgbox(a) 'Shows Jan Feb Mar Apr May Jun Jul

Example 5 of VBScript Join
Dim a
Months=Array("Jan","Feb","Mar","Apr","May","Jun","Jul")
a=Join(Months, "$$")
msgbox(a) 'Shows Jan$$Feb$$Mar$$Apr$$May$$Jun$$Jul


Also See:
Complete List of VBScript Array Functions