Empty keyword in statment Application.caption?

M

Mel

I was trying to learn from some code someone else had
written. What is the keyword Empty used for in the
statement below. If I remove the "Empty &" the results
seem to be the same. Is it just a placeholder of some
kind?


Application.Caption = empty & "Microsoft Excel (Alarm Set
for "

Application.Caption = "Microsoft Excel (Alarm Set for "
 
T

Tom Ogilvy

Personally, I have found little in the help to indicate that "empty" is a
key word.

If empty isn't declared as a variable or is declared as Variant and never
initialized, then it would represent the value of an uninitialized variable.
Used in the context you show, it would be equivalent to a null string, so it
does nothing that I can see.
 
C

Chip Pearson

Empty is a keyword indicating that a Variant type variable has no
contents. E.g.,

Dim V As Variant
Debug.Print V = Empty
V = 123
Debug.Print V = Empty
V = Empty
Debug.Print V = Empty


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
T

Tom Ogilvy

substitute Horseradish for empty and see if you don't get the same result.

Sub Tester2()
Dim V As Variant
Debug.Print V = HorseRadish
V = 123
Debug.Print V = HorseRadish
V = HorseRadish
Debug.Print V = HorseRadish
End Sub

gives the same result for me.

If you have a reference, please post it.
 
D

Dave Peterson

From VBA's help in xl2002:

Empty
The Empty keyword is used as a Variant subtype. It indicates an uninitialized
variable value.


It even turns blue like "if" and "then".
 
C

Chip Pearson

Since you're not using Option Explicit, VBA creates a new variant
variable called HorseRadish of subtype, yes, Empty (VarType() =
vbEmpty =0).


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
T

Tom Ogilvy

Or declaring it as a variant would achieve the same.

As Dave said, it is highlighted in Blue, so I guess VBA does see it as a
keyword, but it seems of limited utility except for "documentation".
 
Top