如何清除整个数组? [英] How to clear the entire array?

查看:135
本文介绍了如何清除整个数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的数组:

Dim aFirstArray() As Variant

如何清除整个数组?

一个集合呢?

How do I clear the entire array?
What about a collection?

推荐答案

您可以使用擦除 ReDim 语句清除数组:

You can either use the Erase or ReDim statements to clear the array:

Dim threeDimArray(9, 9, 9), twoDimArray(9, 9) As Integer
Erase threeDimArray, twoDimArray
ReDim threeDimArray(4, 4, 9)

a href =http://msdn.microsoft.com/en-us/library/83zyeke9%28VS.80%29.aspx =noreferrer>请参阅此处各种方法的不同用法。

See the different usage of each method here.

更新

要删除集合,项目,并使用删除方法:

To remove a collection, you iterate over its items and use the remove method:

For i = 1 to MyCollection.Count
  MyCollection.Remove 1 ' Remove first item
Next i

这篇关于如何清除整个数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆