Board index » delphi » Delphi DLLs with Visual Basic

Delphi DLLs with Visual Basic

Hi,

I need to write a DLL with Delphi which will have procedures
returning values using the "var" keyword. A simple (trivial)
example would be:

procedure DoubleIT(var Num: integer);
begin
  Num:=Num*2
end;

No problems so far, but the DLL needs to be able to be used
with VB.

 o Can VB handle passing parameters in this manner?
 o Could someone post some VB code which would call the above
   procedure?

Some (most) of the procedures will have records as parameters.

 o How well will VB cope with this?
 o And again, could someone please post some VB code to show
   how this would be done.

Thanks for your help,

Mike Watson

 

Re:Delphi DLLs with Visual Basic


Mike,
  What you will need to do on the VB side is declare the function using
ByRef...
For Example:

             Declare function DoubleT Lib"mydll.dll" (byref NumberIn as
integer) as integer
that will do it..
                                                        Good luck,
                                                                Dave

Mike Watson <m...@d-m-g.demon.co.uk> wrote in article
<886087446...@d-m-g.demon.co.uk>...

Quote
> Hi,

> I need to write a DLL with Delphi which will have procedures
> returning values using the "var" keyword. A simple (trivial)
> example would be:

> procedure DoubleIT(var Num: integer);
> begin
>   Num:=Num*2
> end;

> No problems so far, but the DLL needs to be able to be used
> with VB.

>  o Can VB handle passing parameters in this manner?
>  o Could someone post some VB code which would call the above
>    procedure?

> Some (most) of the procedures will have records as parameters.

>  o How well will VB cope with this?
>  o And again, could someone please post some VB code to show
>    how this would be done.

> Thanks for your help,

> Mike Watson

Re:Delphi DLLs with Visual Basic


In article <01bd2d14$b5553ce0$99c2accf@default>
           dpars...@erols.com "Dave Parsons" writes:

Quote
> Mike,
>   What you will need to do on the VB side is declare the function using
> ByRef...
> For Example:

>              Declare function DoubleT Lib"mydll.dll" (byref NumberIn as
> integer) as integer
> that will do it..
>                                                         Good luck,
>                                                                 Dave

Thanks for this, Dave.

In your example, you have the function returning a value ( the "as
integer" after the close bracket). Presumably VB will allow me to do
it like:

  declare function DoubleIT lib"mydll.dll" (byref NumberIn as integer)

??

Thanks again,

Mike

Quote

> Mike Watson <m...@d-m-g.demon.co.uk> wrote in article
> <886087446...@d-m-g.demon.co.uk>...
> > Hi,

> > I need to write a DLL with Delphi which will have procedures
> > returning values using the "var" keyword. A simple (trivial)
> > example would be:

> > procedure DoubleIT(var Num: integer);
> > begin
> >   Num:=Num*2
> > end;

> > No problems so far, but the DLL needs to be able to be used
> > with VB.

> >  o Can VB handle passing parameters in this manner?
> >  o Could someone post some VB code which would call the above
> >    procedure?

> > Some (most) of the procedures will have records as parameters.

> >  o How well will VB cope with this?
> >  o And again, could someone please post some VB code to show
> >    how this would be done.

> > Thanks for your help,

> > Mike Watson

--
Denison Mayes Group

Other Threads