I=1
Disct=0
The Do While I & lt; M=
Disct1=(1 + y) ^ (-i)
Disct=disct + disct1
Loop
Disctm=(1 + y) ^ (-m)
Bond=(disct * couponRate + disctm) * face
End the Function
Sub bondTester ()
Y=0.03
Face=2000000
CouponRate=0.04
M=10
MsgBox (Bond (y, face, couponRate, m))
End Sub
Run code displayed when invalid outside procedure.
CodePudding user response:
Is a Function rather than FuntionCodePudding user response:
Function Bond (y, face, couponRate, m)
I=1
Disct=0
The Do While I & lt; M=
Disct1=(1 + y) ^ (-i)
Disct=disct + disct1
Loop
Disctm=(1 + y) ^ (-m)
Bond=(disct * couponRate + disctm) * face
End the Function
Sub bondTester ()
Y=0.03
Face=2000000
CouponRate=0.04
M=10
MsgBox (Bond (y, face, couponRate, m))
End Sub
CodePudding user response:
Thank you very much! I have a try!