Maybe it sounds like cheating, but I just used the existing VB financial library .NET has. Its for annuities so you have to make the payment a negative number.
Term is full number of payments(i.e. 15 year mortgage has 180 payments so 180) Payment is payment per (so monthly payment amt... x -1) Starting Amount = original loan amount with no fees
double apr = Microsoft.VisualBasic.Financial.Rate(term,-payment,originalLoanAmt)
Then just multiply by the answer by the annual # of payments (if monthly then 12) or if you want the % expressed as a number like 3.25%, then multiply by 100 as well.
**note you have to add a reference to Microsoft.VisualBasic assembly.