devxlogo

Duplicate the Join Function for VB4 and VB5

Duplicate the Join Function for VB4 and VB5

The native VB6 Split and Join functions have highlighted a number of useful techniques, and VB5 and VB4 programmers can use this extended facility as well. This code emulates the Join function of VB6 for use in earlier versions. This function takes in an array of information and gives a String as output with delimiters per the user request:

 Public Function Join(arr As Variant, Optional _ByVal delimiter) As StringDim sRet As StringDim i As IntegerIf IsArray(arr) ThenIf IsMissing(delimiter) Thendelimiter = " "ElseIf Len(CStr(delimiter)) = 0 Thendelimiter = ""Elsedelimiter = CStr(delimiter)End IfFor i = LBound(arr) To UBound(arr)sRet = sRet & arr(i) & delimiterNext iEnd IfJoin = Left(sRet, Len(sRet) - Len(delimiter))End Function

devx-admin

Share the Post: