October 23rd, 2002, 5:14 am
Im not a expert for C++, but I would like to share a MS VC++ that being called from VBA. Basically, I have a spreadsheet that capture all details of input parameters. Then these parameters will be pass into a C++ program to perform the Monte Carlo Simulation (MCS) and output the result back to the spreadsheet.VBA Code:Option ExplicitDeclare Function mcs Lib _"c:\tb\C++\BasketMCS\Debug\BasketMCS.dll" _(ByVal nDef As Long, dEndDate As Double, dNonDefCF As Double, _ ByVal dNotional As Double, ByVal dDC As Double, ByVal nZeros As Long, _ dZeroTs As Double, dZeros As Double, ByVal nRowDef As Long, _ ByVal nColDef As Long, dCDefTs As Double, dCDefault As Double, _ dCholesky As Double, dRR As Double, ByVal inSim As Long, _ ByVal iSeed As Long, ByVal antithetic As Boolean) As DoubleC++ code:double _stdcall mcs(int nDef, double *EndDate, double *NonDefCF, double Notional, double DC, int nZeros, double *ZeroTs, double *Zeros, int nRowDef, int nColDef, double *CDefTs, double *CDefault, double *cholesky, double *RR, int nSim, int iSeed, bool antithetic) { computation....return output;}U need to create a new text file in yr C++ console application with contents:EXPORTSmcs @1Hope that I provided u with alternative for dll....RgdsRocco