Contents
Index 🔎︎

# Join Function

從字串陣列中的多個子字串中傳回一個字串。

### Syntax:

    Join (Text As String Array, delimiter)

### Return value:

String

### Parameters:

Text：字串陣列。

delimiter (可選)：用於將傳回的字串中的子字串分隔開的一個字串字元。標準的分割元為空格字元。如果分隔字元是一個零長度字串 ""，則子字串將緊密相接，相互間無分隔符。

### Example:

    Dim a(3)
    Sub main()
        a(0) = "ABCDE"
        a(1) = 42
        a(2) = "MN"
        a(3) = "X Y Z"
        JStr = Join1()
        Call Show(JStr, Split1(JStr))
        JStr = Join2()
        Call Show(JStr, Split1(JStr))
        JStr = Join3()
        Call Show(JStr, Split1(JStr))
    End Sub

    Function Join1()
        Join1 = Join(a(), "abc")
    End Function

    Function Join2()
        Join2 = Join(a(), ",")
    End Function

    Function Join3()
        Join3 = Join(a())
    End Function

    Function Split1(aStr)
        Split1 = Split(aStr, "D")
    End Function

    Sub Show(JoinStr, TheArray)
        l = LBound(TheArray)
        u = UBound(TheArray)
        total$ = "=============================" + Chr$(13) + JoinStr + Chr$(13) + Chr$(13)
        For i = l To u
            total$ = total$ + TheArray(i) + Str(Len(TheArray(i))) + Chr$(13)
        Next i
        MsgBox total$
    End Sub

相關主題

String functions