Simulating VB Nothing variant in Delphi



Often in VB code you see statements like:

Set cmd.ActiveConnection = Nothing
or
Set dbs = Nothing

To simulate Nothing in Delphi use:
var
vntNothing: OLEVariant;
begin
TVarData(vntNothing).VType := varDispatch;
TVarData(vntNothing).VDispatch := Nil;
// then you can do things like..
cat.Set_ActiveConnection(vntNothing);
without getting a data type mismatch.

Ian.


.