Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing a Variable that gets changed by a DLL
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00734533
Message ID:
00734874
Views:
16
Hey Ellis. My response to your question has turned into more of a discussion with Gerry, and it occurs to me that it might make sense to also answer you directly with some code samples.

If you have a VB Class with function definitions that look something like this:
Public Function TestByRef(ByRef varSomeVariable As Variant) As Variant
    varSomeVariable = "Changed"
    TestByRef = True
End Function

Public Function TestByVal(ByVal varSomeVariable As Variant) As Variant
    varSomeVariable = "Changed"
    TestByVal = True
End Function
Then, in from VFP you can do the following:
ox = CREATEOBJECT("ByRef_ByVal.ByRef_ByVal_Class")
liTest = 0
? ox.TestByVal(@liTest)
? liTest && prints 0
liTest = 0
? ox.TestByRef(@liTest)
? liTest   && prints 1
That should be all there is to it. Is there something about the VB declaration that looks very different from this example?


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>Help! I'm having difficulty with the proper way to pass a variable to a VB dll subroutine that changes the variable: Here's my code:
>
>Public RetVal
>RetVal = 0
>LOGS = createobject("LogServer.ActivityLogServer")
>LOGS.Log("Root",101,14,RetVal)
>
>... The dll subroutine "Log" works perfectly receiving the first 3 parameters. The problem is that "RetVal" is not getting set by Log (RetVal always stays at 0). I've also tried:
>
>LOGS.Log("Root",101,14,@RetVal)
>
>In the VB declaration, "RevVal" is declared as Variant. A VB test application proves that RetVal, is getting set correctly.
>
>What do I need to do so RetVal picks up the change made by the dll?
>
>Thanks!!!!
>
>Ellis
The whole problem with the world is that fools and fanatics are always so certain of themselves, but wiser people so full of doubts. - Bertrand Russell
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform