当前位置: 首页 > 文档资料 > VBA 中文教程 >

Join

优质
小牛编辑
114浏览
2023-12-01

一个Function,它返回一个字符串,该字符串包含数组中指定数量的子字符串。 这与Split Method完全相反。

语法 (Syntax)

Join(List[,delimiter]) 

参数描述 (Parameter Description)

  • List - 必需参数。 包含要连接的子字符串的数组。

  • Delimiter - 可选参数。 该字符,在返回字符串时用作分隔符。 默认分隔符是Space。

例子 (Example)

添加按钮并添加以下功能。

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