PDA

View Full Version : Problem with VBA, not with VB 6.0



fgabriel
05-22-2006, 04:10 AM
Dear all, my first post :hi:

So my problem :banghead: :
- I have developed in C++ (with Visual C++) 2 DLLs, "app1.dll" and "app2.dll". "app1.dll" calls functions in "app2.dll" via explicit linking (with LoadLibrary). "app2.dll" contains only algorithms whereas "app1.dll" contains wrapper functions using SAFEARRAY structures so that I can call safely functions using arrays, from VB/VBA.

- In order to test app1.dll, I have developed a VB 6.0 project which works perfectly well and returns the expected values: the arrays of VB are perfectly handled, the values contained in the arrays are modified according to the algorithms contained in app2, the program returns the initial arrays but with modified values.

- When transferring the code to Excel/VBA, I have the following problem: the returned values in the arrays are not modified at all, as if the program has ignored the app2.dll step: the values are passed to app2 during explicit linking, but with no effects on the values in app1. In order to confirm my suspicion, I developped another code in app1 which modifies the arrays in app1 directly without calling app2 and this code works well when called from Excel/VBA.

Is this a flaw in Excel/VBA? How can I solve it? I do not want to put all my code in one single dll :think: