|
-
Apr 21st, 2009, 05:16 AM
#1
Thread Starter
Addicted Member
[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
-
Apr 21st, 2009, 05:24 AM
#2
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)
-
Apr 21st, 2009, 05:27 AM
#3
Fanatic Member
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)
-
Apr 21st, 2009, 05:32 AM
#4
Re: how to say a variant "is nothing" or "is null"?
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)
-
Apr 21st, 2009, 05:43 AM
#5
Thread Starter
Addicted Member
Re: how to say a variant "is nothing" or "is null"?
thanks, isempty() is good.
i tested it
-
Apr 21st, 2009, 07:24 AM
#6
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|