Re: Simulating VB Nothing variant in Delphi



In most cases Unassigned (or Null) will work, however in few special cases
IDispatch(nil) should be used instead of Unassigned (some ActiveX components
may have different actions for these two).

//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)



"Steve Zimmelman" <skz@xxxxxxxxxxxxxxxxxx> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ
ÓÌÅÄÕÀÝÅÅ: news:449bd5c9$1@xxxxxxxxxxxxxxxxxxxxxxxxx
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
    ... 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 ... 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)