VBA Erase()函数-杨雪
Access软件网QQ交流学习群(群号码198465573),欢迎您的加入!
首页 >技术文章> Access数据库-模块/函数/VBA


VBA Erase()函数

发表时间:2019/8/3 20:39:32 评论(0) 浏览(4336)  评论 | 加入收藏 | 复制
   
摘 要:Erase()函数用于重置固定大小数组的值并释放动态数组的内存。 它的行为取决于数组的类型。
正 文:
语法
Erase ArrayName

固定数值数组,数组中的每个元素重置为零。
固定字符串数组,数组中的每个元素被重置为零长度 ""。
对象数组,数组中的每个元素被重置为特殊值 Nothing。

例子
添加一个模块,并添加以下代码
Private Sub Constant_demo_Click()
   Dim NumArray(3)
   NumArray(0) = "VBScript"
   NumArray(1) = 1.05
   NumArray(2) = 25
   NumArray(3) = #4/23/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.
   MsgBox ("The value at Zeroth index of NumArray is " & NumArray(0))
   MsgBox ("The value at First index of NumArray is " & NumArray(1))
   MsgBox ("The value at Second index of NumArray is " & NumArray(2))
   MsgBox ("The value at Third index of NumArray is " & NumArray(3))
End Sub

当执行上面的函数时,它会产生下面的输出。

The value at Zeroth 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

Access软件网交流QQ群(群号:198465573)
 
 相关文章
如何判断VBA中的一个数组是否已经定义其维数上限下限  【MDZZ  2017/4/17】
【Access基础】求一维数组的最大值  【缪炜  2018/6/15】
UBound函数、LBound函数、以及得到数组元素个数  【伊西军  2018/8/2】
【Access基础】求一维数组的最小值的自定义函数  【仙来  2018/8/19】
导出Excel报表的时候,激活Excel模版中的数组公式  【易勋  2019/1/31】
索引超出了数组界限(Microsoft.SqlServer.Smo...  【周韶璋  2019/4/2】
VBA二维数组的基础介绍  【杨雪  2019/5/18】
常见问答
技术分类
相关资源
文章搜索
关于作者

杨雪

文章分类

文章存档

友情链接