Vbscript-erase-function

提供:Dev Guides
移動先:案内検索

VBScript消去関数

消去機能は、固定サイズの配列の値をリセットし、動的配列のメモリを解放するために使用されます。 配列のタイプに応じて動作します。

構文

Erase ArrayName
  • 固定数値配列。配列内の各要素はゼロにリセットされます。
  • 固定文字列配列。配列の各要素は長さゼロの ""にリセットされます。
  • オブジェクトの配列。配列の各要素は特別な値「なし」にリセットされます。

<!DOCTYPE html>
<html>
   <body>
      <script language = "vbscript" type = "text/vbscript">
         Dim NumArray(3)
         NumArray(0) = "VBScript"
         NumArray(1) = 1.05
         NumArray(2) = 25
         NumArray(3) = #23/04/2013#

         Dim DynamicArray()
         ReDim DynamicArray(9)   ' Allocate storage space.

         Erase NumArray          ' Each element is reinitialized.
         Erase DynamicArray      ' Free memory used by array.

         ' All values would be erased.
         Document.write("The value at Zeroth index of NumArray is " & NumArray(0) & "<br/>")
         Document.write("The value at First index of NumArray is " & NumArray(1) & "<br/>")
         Document.write("The value at Second index of NumArray is " & NumArray(2) & "<br/>")
         Document.write("The value at Third index of NumArray is " & NumArray(3) & "<br/>")

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

上記のコードが.HTMLとして保存され、Internet Explorerで実行されると、次の結果が生成されます-

The value at Zero index of NumArray is
The value at First index of NumArray is
The value at Second index of NumArray is
The value at Third index of NumArray is