[RESOLVED] how to say a variant "is nothing" or "is null"?
Dear all,
I have the following declaration in the top of a form:
Public my_global_Array As Variant
then, in a function, I want to check if this my_global_Array has "content" or not. In case it does not have content (it is null or it is nothing), I will load some data from recordset to this array.
But I dont know how to check if it is nothing. I have tried the following codes:
If (my_global_Array = "") Or (my_global_Arrays Is Null) or (my_global_Array is nothing) Then
call sub_load_rs
End If
It returns a fail message which says: "Object required."
What is the code for an variant is nothing?
Thanks :wave:
Re: how to say a variant "is nothing" or "is null"?
Assuming it would be an array you can try using the IsArray function.
Code:
Dim my_global_Array As Variant
MsgBox IsArray(my_global_Array)
Re: how to say a variant "is nothing" or "is null"?
In think you can use one of these to check:
IsNull(my_global_Array)
IsEmpty(my_global_Array)
Re: how to say a variant "is nothing" or "is null"?
Quote:
The value Empty denotes a Variant variable that hasn't been initialized (assigned an initial value). A Variant containing Empty is 0 if it is used in a numeric context and a zero-length string ("") if it is used in a string context.
Don't confuse Empty with Null. Null indicates that the Variant variable intentionally contains no valid data.
Use IsEmpty(v)
Re: how to say a variant "is nothing" or "is null"?
thanks, isempty() is good.
i tested it :thumb:
Re: [RESOLVED] how to say a variant "is nothing" or "is null"?
Just for completeness, "Is Nothing" only works on objects, which is why you were getting the Object Required error message.