Home

Finance Functions:
The Number of Periods of an Investment

 

The NumberOfPeriods() function calculates the number of periodic payments of an investment. Its syntax is:

Extended __fastcall PeriodPayment(constExtended Rate,
                                  int Period,
                                  int NPeriods,
                                  const Extended PresentValue,
                                  const Extended FutureValue,
                                  TPaymentTime PaymentTime);

Here is an example:

//---------------------------------------------------------------------------
void __fastcall TForm1::btnCalculateClick(TObject *Sender)
{
	Extended Present, Future, TheRate, Payments, NPeriod;
	
	Present = StrToFloat(edtLoan->Text);
	Future = StrToFloat(edtFuture->Text);
	Payments = StrToFloat(edtPayments->Text);
	TheRate = StrToFloat(edtRate->Text) / 12;
	
	double Rate = TheRate / 100;
	// Apply the function
	NPeriod = NumberOfPeriods(Rate, -Payments, -Present,
	Future, ptStartOfPeriod);
	// Since the number of periods is really an integer, find its ceiling
	Extended Actual = Ceil(NPeriod);
	// Display the number of periods
	edtNPeriods->Text = FloatToStr(Actual);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnExitClick(TObject *Sender)
{
	PostQuitMessage(0);
}
//---------------------------------------------------------------------------
 
Home Copyright 2004 FunctionX, Inc.