Solved

# PMT options in C#

Posted on 2004-08-20

THis is my question i am converting some old vb6 project to C#. One uses the pmt function. I know that if i Microsoft.VisualBasic as a reference i can use this same function. Most people are not happy with me using this.

so here is the function i found

present value = 10000, financial period is 119 months and interest rate is = .129

public Double calculate_Amount(double presentValue, double

financingPeriod,

double interestRatePerYear)

{

try

{

double a, b, x,g;

double monthlyPayment;

double vbMnthlyPayment;

a = (1 + interestRatePerYear / 12);

b = financingPeriod;

x = Math.Pow(a, b);

x = 1 / x;

x = 1 - x;

//this is the C# way i get a value of 149.33

monthlyPayment = (presentValue ) * (interestRatePerYear / 12) / x;

// this is the vb way i get a value of 150.94

vbMnthlyPayment = Microsoft.VisualBasic.Financial.Pmt(interestRatePerYear/12,financingPeriod,-(presentValue*(1+interestRatePerYear/12)),0,0);

return(monthlyPayment);

The vb reference is that amount that i need to keep conistent but i dont know how to change the C# function to return the same answer

please help!!