| IsEmpty Function |
Named Arguments
No
Syntax
IsEmpty(varname)
varname
Use: Required
Data Type: Variant
A numeric or string expression.
Return Value
Boolean (True or False).
Description
Determines if the variable has been initialized by having an initial value (other than Empty) assigned to it.
Rules at a Glance
If the variant passed to IsEmpty has been initialized, True is returned; otherwise, IsEmpty returns False.
IsEmpty works only with variants. You shouldn't use it with the primitive data types (such as Integer, String, etc.) because these data types are automatically initialized with default values and therefore are never empty.
Although IsEmpty can take an expression as the value of varname, it always returns False if more than one variable is used in the expression. IsEmpty is therefore most commonly used with single variables.
Programming Tips and Gotchas
When dealing with uninitialized object variables, if a reference to an object variable has not been successfully set, the variable has a value of Nothing. However, to determine if an object variable has been set successfully, you must use the syntax:
If objvar is Nothing Then ... End If
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access