Rodrigo Gómez
Rodrigo Gómez

Reputation: 1079

What is the difference between Variant.IsEmpty and Variant.IsNull?

According to the help (IsEmpty, IsNull), both return true

if the VType field of the TVarData base class is varEmpty

I don't know if there is some subtle difference between both methods, or which one is the best/correct one to check to see if a Variant value has any data or not.

Upvotes: 1

Views: 518

Answers (1)

Rudy Velthuis
Rudy Velthuis

Reputation: 28806

Generally Null indicates missing or unknown data. Empty indicates no data.

Think of a phone number field. If you don't know if someone has a telephone number at all, the field should be Null. If you know that someone doesn't have a telephone, then the field should be Empty.

Despite what the documentation says, IsEmpty checks for a value of varEmpty and IsNull checks for a value of varNull.

Upvotes: 2

Related Questions