In the nearest window you can use the following:
?Result Is Nothing ?IsNull( Result ) ?IsEmpty( Result ) ?IsMissing( Result )
The first is just for completeness. Since Result is not an object, Result Is Nothing will throw an error. Empty for options that have not been initialized , including arrays that have not been defined. .
(Update) When performing an additional check, I found that IsEmpty will never return true in the declared array (whether Redim'd or not) with only one exception. The only exception I found is when the array is declared at the module level, and not as Public, and then only when you check it in the immediate window.
Missing if a function is passed to or for sub values. While you cannot declare Optional Foo() As Variant , you can have something like ParamArray Foo() As Variant , in which case if nothing is passed, IsMissing will return true.
Thus, the only way to determine if an array is initialized is to write a procedure that checks:
Public Function IsDimensioned(vValue As Variant) As Boolean On Error Resume Next If Not IsArray(vValue) Then Exit Function Dim i As Integer i = UBound(Bar) IsDimensioned = Err.Number = 0 End Function
Btw, it should be noted that this routine (or the library laid out by Jean-Francois Corbett) will return false if the array is specified and then deleted.
source share