Join()
函數返回一個包含數組中指定數量的子串的字串。這是Split
方法的一個完全相反的功能。
語法
Join(List[,delimiter])
參數說明
- List - 必需的參數。包含要連接的子字串的數組。
- Delimiter - 一個可選參數。該參數用於根據分隔符號轉換為數組。
例子
添加一個模組,並添加以下代碼 -
Private Sub Constant_demo_Click()
' Join using spaces
a = array("Red","Blue","Yellow")
b = join(a)
msgbox("The value of b " & " is :" & b)
' Join using $
b = join(a,"$")
msgbox("The Join result after using delimiter is : " & b)
End Sub
當執行上面的函數時,它會產生下麵的輸出。
The value of b is :Red Blue Yellow
The Join result after using delimiter is : Red$Blue$Yellow
上一篇:
VBA數組
下一篇:
VBA用戶自定義函數