如何从VBA标准库像IsEmpty()重载函数?
我想在这样的一个类中创build一个IsEmpty()
的本地版本:
Public Dict As Dictionary Public Function isEmpty(columnName As Variant) As Boolean isEmpty = IsEmpty(Dict(columnName)) End Function
这是为了信息隐藏,所以我可以打电话
classInstance.isEmpty("someField")
代替
isEmpty(classInstance.Dict("someField"))
因此不会暴露课程的内部数据结构。
但问题是,我声明的isEmpty()
版本似乎是重写了对IsEmpty()
的VBA库版本的任何引用,因为它会生成Out of stack
错误并导致Excel崩溃。 我认为这是因为isEmpty = IsEmpty(...)
调用导致无限recursion。
有没有一种方法可以明确引用我想在这里调用的标准版本的IsEmpty()
?
是。 明确引用标准库。
VBA.IsEmpty()
奖金:
IsEmpty
实际上属于Information
对象。 完全显式的调用看起来像这样。
bool = VBA.Information.IsEmpty(var)