Ako Musha

Ako Musha

  • NA
  • 28
  • 11.7k

How to calculate internal rate of return (IRR)?

Oct 18 2018 2:25 PM
I have a column in a DataGridView which includes before tax cash flow values. Could someone please help me to calculate the IRR (Internal Rate of Return)?
 
Here is what I have done so far, but getting an error when trying to calculate the IRR function:
 
Error: Value of type 'Double' cannot be converted to '1-dimensional array of Double. this error refers to "val" in the IRR function.
 
Thanks so much for your help! Please consider that, I am new and just start coding VB, thanks !!
 
What I have tried:
  1. Dim prec As String "###,##0.00"  
  2. Dim guess As Double=0.1 For i =0 to DataGridView1.Rows.Count -1  
  3. For j =0 to DataGridView1.Rows.Count -1  
  4. Dim value(j) As Double  
  5. Dim val As Double  
  6. value(j) = DataGridView1.Rows(i).Cells(0).Value  
  7. value(j)=val  
  8. Dim cal As Double = IRR(val,guess) * 100  
  9. MsBox("IRR = " & Format(cal, CStr(prec)) & " % ")  
  10. Text1.Text=cal  
  11. Next  
  12. Next  

Answers (1)