Rated
Read 52,083 times
Contents
Related Categories
Mathematical Functions - Compound Interest
Compound Interest
Here is a little function that calulates the compound interest of an amount,
over the specified period.
Function CompoundInterest(cStartAmount As Currency, fInterestPerPeriod
As Single, lPeriods As Long) As Currency
Dim i As Long
Dim cTotal As Currency
cTotal = cStartAmount
For i = 1 To lPeriods
cTotal = cTotal + (cTotal * (fInterestPerPeriod))
Next i
CompoundInterest = cTotal - cStartAmount
End Function
Private Sub cmdCalculate_Click()
'// 100 = starting amount
'// 0.1 = 10% Interest per period
'// 2 = 2 periods
MsgBox CompoundInterest(100, 0.1, 2)
End Sub
James first started writing tutorials on Visual Basic in 1999 whilst starting this website (then known as VB Web). Since then, the site has grown rapidly, and James has written numerous tutorials, articles and reviews on VB, PHP, ASP and C#. In October 2003, James formed the company Developer Fusion Ltd, which owns this website, and also offers various development services. In his spare time, he's a 3rd year undergraduate studying Computer Science in the UK. He's also a Visual Basic MVP.
Comments
-
Posted by thargyaw on 02 Aug 2008
Thanks for your advice. -
Posted by asdfg on 06 Sep 2006
if ur gettin incorrect ln() output then switch to radian mode or vice versa, which ever you are expecting.
Posted by coolgome2 on 04 May 2005
If you're using the TI-89, the ln(x) function is the same as VB's log(x) function. If you want to use the ti-89's log(x) function in VB, you have to do log(x)/log(10). You should get the right answer.
Posted by chrisgbk on 04 Apr 2005
the VB log function is the natural logarithm (base e), not a base 10 logarithm. the help files/MSDN have samples for making a base10 logarithm function... its something like:
log(number)/log(e), wh... -
Posted by audio.mixer on 12 Mar 2005
I am consistently getting problems with VB's logarithm function. In fact, on my TI-89, log(1.31) returns 0.11727..., not the number you gave, not 0.27... I am trying to write a program to calculate ga...
|