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
廣告