VBA Join函數
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