Skip to content

Instantly share code, notes, and snippets.

@taka2
Created January 18, 2010 07:18
Show Gist options
  • Select an option

  • Save taka2/279853 to your computer and use it in GitHub Desktop.

Select an option

Save taka2/279853 to your computer and use it in GitHub Desktop.
Option Explicit
' 8万円を、30年間、1年複利で、7%で運用
msgbox CalcReinvestment(80000, 12, 30, 0.07)
' 8万円を、30年間、半年複利で、7%で運用
msgbox CalcReinvestment(80000, 6, 30, 0.07)
' 8万円を、30年間、1ヶ月複利で、7%で運用
msgbox CalcReinvestment(80000, 1, 30, 0.07)
' 毎月の積み立て額、再投資頻度、積立期間、予定利率を入力すると、
' トータルリターンを計算する
Function CalcReinvestment(amount, freq, term, ratio)
Dim total, i
total = 0
For i = 1 to (term * 12 / freq)
total = total + amount * freq
total = Round(total * (1 + (ratio / 12 * freq)), 0)
Next
CalcReinvestment = total
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment