IsEmpty Function

See Also7GCG02Y              Example8AC88GK>Low

Returns a value indicating whether or not a Variant8PHEAW3 variable has been initialized.

Syntax

IsEmpty(variant)

Remarks

The argument variant can be any Variant expression.  However, because IsEmpty is used to determine whether or not variables are initialized, the argument is most often a single variable name.  The IsEmpty function returns True if the Variant contains the Empty1L2JEZ4 value; otherwise, it returns False.  When an expression contains more than one Variant, IsEmpty always returns False.

The Empty value indicates that a Variant has not been initialized.  Empty is not the same as Null1DDW7C0, which indicates that a Variant contains no data.


See Also

IsDate Function9B784K

IsNull Function9BAKWR

IsNumeric Function1MXC66A

VarType FunctionXRZH1Y


IsEmpty Function Example

The example uses IsEmpty to determine whether TestVar has been initialized.  If it hasn't been initialized, the user is asked if it should be.  To try this example, paste the code into the Declarations section of a form.  Then press F5 and click the form.

 

Sub Form_Click ()

   Dim InitVar, TestVar                  ' Declare variable.

   If IsEmpty(TestVar) Then              ' Test variable.

      InitVar = MsgBox("TestVar is uninitialized. Initialize now?", 36)

      If InitVar = 6 Then                ' If Yes,

         TestVar = 1.25                  ' initialize TestVar.

         MsgBox "TestVar initialized to " & TestVar

      End If

   End If

End Sub