VBScript Join 函数



返回一个字符串,其中包含数组中指定数量的子字符串。这是 Split 方法的反向函数。

语法

Join(List[,delimiter]) 
  • 列表,所需参数。包含要连接的子字符串的数组。

  • 分隔符,可选参数。返回字符串时用作分隔符的字符。默认分隔符为“空格”。

示例

<!DOCTYPE html>
<html>
   <body>
      <script language = "vbscript" type = "text/vbscript">
         ' Join using spaces
         a = array("Red","Blue","Yellow")
         b = join(a)
         document.write("The value of b " & " is :"  & b & "<br />")

         ' Join using $
         b = join(a,"$")
         document.write("The Join result after using delimiter is : " & b & "<br />")

      </script>
   </body>
</html>

如果将上述代码另存为 .html 并 Internet Explorer 中执行,它将产生以下结果 −

The value of b is :Red Blue Yellow
The Join result after using delimiter is : Red$Blue$Yellow
vbscript_arrays.htm
广告
© . All rights reserved.