Board index » cppbuilder » Checking whether data is there in a variant...???

Checking whether data is there in a variant...???


2005-02-17 02:29:45 PM
cppbuilder109
Hi,
I'm using Borland Delphi 5.
How will check there is any value in a variant? I used the following
code, but its nor working for me. Can any1 help me out?
I want to use the VarArrayLowBound and VarArrayHighBound to get
the min. and max values. But when I use VarIsNull to check whether there
is any data in the variable changed, its not working.
VarIsNull isa always returing false even if its empty or not empty and
it goes in, so it breaks up when I use VarArrayLowBound. The
try...except block is not useful for me in this case and it breaks up @
VarArrayLowBound itself. So the function always return TRUE, it never
returns FALSE.
How to check whether there is any value in the variant CHANGED?
=========================================
procedure TForm1.Button2Click(Sender: TObject);
var
EmployeeData, Changed: Variant;
begin
EmployeeData := CreateOleObject ('CAPVGWY.Employee');
Changed := EmployeeData.WhatsDeleted;
if CheckBounds(Changed) then begin
Showmessage('Data Found...!');
end
else begin
Showmessage('No data found....!');
end;
end;
function TForm1.CheckBounds(const changed: variant): Boolean;
var
iLow: Integer;
begin
Result := True;
try
if not (VarIsNull(changed)) then begin // always returns FALSE
iLow := VarArrayLowBound(Changed, 1); // breaks at this line
end;
Showmessage('ddsds');
except
Result := False; // nevere executes even if no data
end;
end;
Thanks
Rajeev R
 
 

Re:Checking whether data is there in a variant...???

"Rajeev Ramanujan" < XXXX@XXXXX.COM >wrote in message
Quote
How will check there is any value in a variant?
Look at the vt member. It will be VT_EMPTY is no data is available.
Quote
I used the following code, but its nor working for me.
Just saying it does not work says nothing about the actual problem you are
having.
Quote
I want to use the VarArrayLowBound and VarArrayHighBound
to get the min. and max values. But when I use VarIsNull to check
whether there is any data in the variable changed, its not working.
Use VarIsEmpty() instead of VarIsNull(). Better yet, since you are working
with arrays anyway, use VarIsArray().
Quote
VarIsNull isa always returing false even if its empty
As it should be. Empty and Null are two different things.
Gambit