This is my first post, but have been an avid reader up until to now. Great resource though.
Anyway, onto my problem.
I need to use the Microsoft.VisualBasic.Financial.IRR procedure in my C# / ASP.NET 2.0 application.
The code I am using is shown below:-
Expand|Select|Wrap|Line Numbers
- Decimal monthlyROI = 0;
- Decimal ROI = 0;
- Double estimate = 0.1;
- Double[] irrArray;
- ArrayList irrArrayList = new ArrayList();
- irrArrayList.Add((Double)Decimal.Negate(amountOfCredit));
- for (int termLoop = 0; termLoop < (term - 2); termLoop++)
- {
- irrArrayList.Add((Double)standardFinancePayment);
- }
- irrArrayList.Add((Double)Decimal.Add(monthlyFinancePayment, finalPayment));
- irrArray = (Double[])irrArrayList.ToArray(typeof(Double));
- monthlyROI = (Decimal)Microsoft.VisualBasic.Financial.IRR(ref irrArray, estimate);
- ROI = Decimal.Multiply(monthlyROI, 12);
- return ROI;
I thought it might have been to do with using the array list, and then populating the array with the contents of it.
I tried just using a standard Double Array and then assigning its size when it was instantiated. THis too didnt work.
The only way I can get this function to work correctly is by instantiating the array with values at design time as follows:-
Expand|Select|Wrap|Line Numbers
- Double[] irrArray = {-22500.00, 770, 770, 600, 500, 7770, 666,555,444,666,666};
Regards
Simon