Re: Simulating VB Nothing variant in Delphi



Mike is correct. Use UnAssigned when using COM and OleVariants.

********************
From Delphi Help:
********************
In the code fragment shown below, the statement that assigns Unassigned to the
MSWord variable causes the OLE Automation Object that was created to interface
with Word to be released.

var
MSWord: Variant;
begin
...
MSWord := CreateOleObject('Word.Basic');
...
MSWord := Unassigned;
...
end;
********************

In VB it would be [Set MSWord = Nothing].

-Steve-

"Ian Hinson" <pparagon@xxxxxxxxxxxxxx> wrote in message
news:4499d7fb@xxxxxxxxxxxxxxxxxxxxxxxxx
"Mike Shkolnik" <mshkolnik2002@xxxxxxx> wrote in message
news:4499a17d@xxxxxxxxxxxxxxxxxxxxxxxxx
UnAssigned in Delphi is the same as Nothing in VB
cat.ActiveConnection := UnAssigned;

Have to disagree on that, sorry.
The Unassigned function returns a variant with VType varEmpty,
whereas the Nothing variant in VBA is a variant with VType varDispatch.


.



Relevant Pages

  • Re: How to casting to VARIANT*
    ... > The second parameter to be passed is a range 'object'. ... but I wonder why MSWORD is designed this way. ... in there that just take a plain VARIANT. ... optional are also passed by pointer. ...
    (microsoft.public.vc.atl)
  • Re: Simulating VB Nothing variant in Delphi
    ... IDispatchshould be used instead of Unassigned (some ActiveX components ... the MSWord variable causes the OLE Automation Object that was created to ... The Unassigned function returns a variant with VType varEmpty, ... whereas the Nothing variant in VBA is a variant with VType varDispatch. ...
    (borland.public.delphi.database.ado)