當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


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

當上麵的代碼保存為 .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 

相關用法


注:本文由純淨天空篩選整理自 VBScript Erase Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。