Serving the Quantitative Finance Community

 
User avatar
gauravkumar2
Topic Author
Posts: 3
Joined: May 25th, 2009, 6:08 pm

C++ DLL from Excel

August 10th, 2009, 1:38 pm

Hi AllI have the following simple C++ program:double* __stdcall arr(int n){double *a=new double[n];for(int i=0;i<n;i++)a=1;return a;}I am compilinng the file and getting the DLL file. Could any one tell me how to call this function in VBA and how to use it excel? PS: I posted the query in technical forum and I was told to paste it here. I am sorry for the same.RegardsGaurav
 
User avatar
AlexesDad
Posts: 11
Joined: May 29th, 2009, 4:10 pm

C++ DLL from Excel

August 10th, 2009, 2:01 pm

1. You code is very dangerous. You are allocating memory on the heap and not freeing it.2. If you want to write C++ functions for use in Excel then write XLLs and you won't need the VBA wrappers.
Last edited by AlexesDad on August 9th, 2009, 10:00 pm, edited 1 time in total.
 
User avatar
gauravkumar2
Topic Author
Posts: 3
Joined: May 25th, 2009, 6:08 pm

C++ DLL from Excel

August 11th, 2009, 4:27 am

I can not write XLL because of some technical problems. I have to work with DLL
 
User avatar
AlexesDad
Posts: 11
Joined: May 29th, 2009, 4:10 pm

C++ DLL from Excel

August 11th, 2009, 4:36 am

See this thread.Out of curiosity, what technical problems ?