I'm reading data into arrays from a spreadsheet using a VBA macro, which then passes them to a C++ DLL in a function that uses SAFEARRAY e.g.:
in VBA: Call Cholesky(IssuerCorrel(), CF(), ByVal IssuerCount)
in C++: void __declspec (dllexport) __stdcall Cholesky(
SAFEARRAY **IssuerCorrel, SAFEARRAY **CF, short IssuerCount)
The DLL identifies new arrays pointing at the same memory locations e.g.:
double* CFc;
CFc = (double*)(*CF)->pvData;
CFc[0]= *CFc;
reads some arrays, and writes to others. The program then returns to VBA and writes the results back to the spreadsheet.
I keep getting access violations, either reading or writing to the arrays in C++, that lock up excel. I got one version to run, and it looped through the Call Cholesky part 50,000 times per run for 5 or 6 runs. Then I expanded the DLL and haven't got it to run again.
I've been at this for a week. Read tons of articles and forum tips. Can anyone tell me what I'm doing wrong? I'm using Visual Studio.net 2003, excel 2000 and windows xp.
in VBA: Call Cholesky(IssuerCorrel(), CF(), ByVal IssuerCount)
in C++: void __declspec (dllexport) __stdcall Cholesky(
SAFEARRAY **IssuerCorrel, SAFEARRAY **CF, short IssuerCount)
The DLL identifies new arrays pointing at the same memory locations e.g.:
double* CFc;
CFc = (double*)(*CF)->pvData;
CFc[0]= *CFc;
reads some arrays, and writes to others. The program then returns to VBA and writes the results back to the spreadsheet.
I keep getting access violations, either reading or writing to the arrays in C++, that lock up excel. I got one version to run, and it looped through the Call Cholesky part 50,000 times per run for 5 or 6 runs. Then I expanded the DLL and haven't got it to run again.
I've been at this for a week. Read tons of articles and forum tips. Can anyone tell me what I'm doing wrong? I'm using Visual Studio.net 2003, excel 2000 and windows xp.