January 1, 2005

WinTask - Join

'
' Join - Concatenate an array of strings,
'        inserting a separator between each
'
' Author - Joe Strazzere
'
Dim MyArray$(100)

MyArray$(0) = "Abc"
MyArray$(1) = "B"
MyArray$(2) = "C"
MyArray$(3) = "Defghij"

'
' Loop through the array, concatenating each element
' and inserting a separator
'
i=0
Result$=""
Separator$=","  ' The separator

While MyArray$(i) <> ""
 Result$=Result$+MyArray$(i)+Separator$
 i=i+1
Wend

'
' Now, remove the extra separator at the end
'
Result$=Left$(Result$,Len(Result$) - 1)

MsgBox(Result$)