I have a function in VBA that usually returns an array. If there is nothing to return it returns an empty variable (b = empty
). I have some code to loop though the array but I get an error if the variable is not an array. How can I make an if statement that doesn't cause its own error. I have tried
我在VBA中有一个通常返回数组的函数。如果没有要返回的内容,则返回一个空变量(b =空)。我有一些代码循环通过数组但如果变量不是数组我得到一个错误。如何创建一个不会导致自身错误的if语句。我努力了
if not b = empty then
'do the loop
end if
but this gives an error when b is an array Similarly I get error for b = null
, b = nothing
, b(1,1) = ""
etc.
但是当b是一个数组时,这会给出一个错误。同样地,我得到b = null,b = nothing,b(1,1)=“”等的错误。
What is the best way to check this?
检查这个的最佳方法是什么?