Función de borrado de VBScript

La función de borrado se utiliza para restablecer los valores de matrices de tamaño fijo y liberar la memoria de las matrices dinámicas. Se comporta según el tipo de matrices.

Sintaxis

Erase ArrayName
  • Matriz numérica fija, cada elemento de una matriz se restablece a cero.

  • Matriz de cadena fija, cada elemento de una matriz se restablece a la longitud cero "".

  • Matriz de objetos, cada elemento de una matriz se restablece al valor especial Nothing.

Ejemplo

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

Cuando el código anterior se guarda como .HTML y se ejecuta en Internet Explorer, produce el siguiente resultado:

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