On Dec 18, 2006, at 4:32 PM, Jim Dossey wrote:

I have a question about using ByRef in Declares and Function calls.

Say I need to call an OS function using a Declare, and that function needs a pointer to a 4 byte integer in order to return some value. I would call
this function like this:

Dim i As Integer
Declare Sub SomeFunc Lib "somelib" (ByRef Data As Integer)
SomeFunc(i)

The returned value is now in 'i'.

But what happens when this code is in a subroutine that I need to call, and
pass in the integer pointer?  Now that code looks ike this:

Sub MyFunc (ByRef i As Integer)
Declare Sub SomeFunc Lib "somelib" (ByRef Data As Integer)
SomeFunc(i)
End Sub

and I call this using

Dim x As Integer
MyFunc(x)

Now I'm using ByRef twice. So when I call SomeFunc am I going to pass a
pointer to a pointer to 'x'?
_______________________________________________


Probably. But why would you define a subroutine that takes a parameter by reference?

Charles Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to