See Also Example
Returns a value indicating whether or not a Variant variable has been initialized.
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 Empty 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 Null , which indicates that a Variant contains no data.
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