VBScript:Erase函数

目录

Erase函数用于重置固定大小的数组的值并释放动态数组的内存。它的行为取决于数组的类型。

语法

Erase ArrayName
  • 固定数值数组,将数组中的每个元素重置为零。
  • 固定字符串数组,数组中的每个元素都重置为零长度“”。
  • 对象数组,将数组中的每个元素重置为特殊值Nothing。

<!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>

结果:

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

作者:terry,如若转载,请注明出处:https://www.web176.com/vbscript/1199.html

(0)
打赏 支付宝 支付宝 微信 微信
terryterry
上一篇 2020年12月8日 上午11:13
下一篇 2020年12月8日 下午2:38

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注