VBA:如何将Variant归零?

6 vba variant

我有以下Variant:

Dim comboitems() As Variant
Run Code Online (Sandbox Code Playgroud)

我在所有代码中用作包含ComboBox控件值的数组.

在代码的某个点上,我需要清除/ empty/null comboitems().我能怎么做?我尝试了以下所有选项但没有成功.

comboitems = ""
comboitems = Null
comboitems = Nothing
Set comboitems = ""
Set comboitems = Null
Set comboitems = Nothing
comboitems() = ""
comboitems() = Null
comboitems() = Nothing
Set comboitems() = ""
Set comboitems() = Null
Set comboitems() = Nothing
Run Code Online (Sandbox Code Playgroud)

我得到的错误是这样的:

在此输入图像描述

Joh*_*Ink 5

对于变量阵列,您可以使用擦除命令将其清除。

Erase comboitems
Run Code Online (Sandbox Code Playgroud)

这是在vba中处理数组的便捷参考指南:

https://excelmacromastery.com/excel-vba-array/