How to pass parameters from VBA to a DLL file or an API

How to pass parameters from VBA to a DLL file or an API



I'm trying to delegate a huge processing VBA code to an outside application. My outside application can be a DLL file or an API.
To do that I need to pass parameters from VBA to a DLL file Or the API. These parameters can be string, integer or an Array.
I already found an example on how to pass Integers from VBA to DLL file



this is my C# code that have as an input three integers which will be sent by VBA. In this example I just generate the DLL file and I call it in VBA, but I need to do the same with arrays.


[Guid("A33BF1F2-483F-48F9-8A2D-4DA68C53C13B")]
[ClassInterface(ClassInterfaceType.AutoDual)]
[ComVisible(true)]
public class MyFunctions

public MyFunctions()




public double MultiplyNTimes(double number1, double number2, double timesToMultiply)

double result = number1;
for (double i = 0; i < timesToMultiply; i++)

result = result * number2;

return result;




How can I pass arrays from VBA TO DLL file or API ?






Where is your vba code?

– QHarr
Sep 18 '18 at 11:25







How do you invoke this code from your VBA? How do you pass values to it? What happens when you try passing a more complex type?

– David
Sep 18 '18 at 11:27






This is what i'm asking @David I need to do the same thing with more complexe variable types like arrays or matrixs and not only integers.

– Soufien Hajji
Sep 18 '18 at 11:41






@QHarr it's all in the response of this question : stackoverflow.com/questions/37074533/…

– Soufien Hajji
Sep 18 '18 at 11:41






Pass an array from vba to c# using com-interop ?

– Alex K.
Sep 18 '18 at 12:23




0



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)