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:
- Dim prec As String "###,##0.00"
- Dim guess As Double=0.1 For i =0 to DataGridView1.Rows.Count -1
- For j =0 to DataGridView1.Rows.Count -1
- Dim value(j) As Double
- Dim val As Double
- value(j) = DataGridView1.Rows(i).Cells(0).Value
- value(j)=val
- Dim cal As Double = IRR(val,guess) * 100
- MsBox("IRR = " & Format(cal, CStr(prec)) & " % ")
- Text1.Text=cal
- Next
- Next