[問題] VBA的日期表達問題
※ [本文轉錄自 Wanted 看板]
作者: hpevd (learning) 看板: Wanted
標題: [問題] VBA的日期表達問題
時間: Sat Aug 22 21:21:48 2009
想請問一下
下面這個式子 表示的是
若到期日在一年內 則用單利折現
若在一年以上 則用複利折現
Public Sub main()
Dim cf, rate, p As Double
Dim maturity, today As Date
MsgBox (Date)
cf = Val(InputBox("請輸入現金流量"))
rate = Val(InputBox("請輸入利率"))
maturity = Val(InputBox("請輸入到期日"))
today = Date
If (maturity < (365 + today)) Then
p = cf / (1 + rate * ((maturity - today) / 365))
Else
p = cf / (1 + rate) ^ ((maturity - today) / 365)
End If
MsgBox p
End Sub
可是折出來的都是負的?
不知道是不是日期那邊的問題?
那我該怎麼修正呢?
麻煩指導一下 謝謝!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.112.140.232
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.112.140.232
推
08/22 22:37, , 1F
08/22 22:37, 1F
推
08/22 22:37, , 2F
08/22 22:37, 2F
→
08/22 22:38, , 3F
08/22 22:38, 3F