【问题标题】:VBA: how to null a Variant?VBA:如何使变体为空?
【发布时间】:2017-12-22 09:59:25
【问题描述】:

我有以下变体:

Dim comboitems() As Variant

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

在代码的某一点,我需要清除/清空/空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

我得到的错误是这样的:

【问题讨论】:

  • Erase comboitems 也许?
  • ReDim 没有preserve?

标签: vba variant


【解决方案1】:

对于变体数组,您可以使用擦除命令清除它们。

Erase comboitems

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

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

【讨论】:

    猜你喜欢
    • 2016-05-28
    • 1970-01-01
    • 1970-01-01
    • 2011-03-20
    • 2020-05-20
    • 2019-06-02
    • 1970-01-01
    • 1970-01-01
    • 2023-03-28
    相关资源
    最近更新 更多