Created
January 10, 2017 15:44
-
-
Save martinusso/7542d7fd5b4e6dee47aec49291263f02 to your computer and use it in GitHub Desktop.
Check if Variant is empty or null in Delphi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// uses System, Variants | |
function IsEmptyOrNull(const Value: Variant): Boolean; | |
begin | |
Result := VarIsClear(Value) or VarIsEmpty(Value) or VarIsNull(Value) or (VarCompareValue(Value, Unassigned) = vrEqual); | |
if (not Result) and VarIsStr(Value) then | |
Result := Value = ''; | |
end; |
Exactly what i was looking for, thank you.
In case your default values are 0 or another precise value :
if (not Result) and VarIsNumeric(Value) then
Result := Value = 0;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!