Home > Software engineering >  Vba small white consult! Where is this way for the bond value code has a problem?
Vba small white consult! Where is this way for the bond value code has a problem?

Time:09-16

Funtion 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

Run code displayed when invalid outside procedure.

CodePudding user response:

Is a Function rather than Funtion

CodePudding 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!
  •  Tags:  
  • VBA
  • Related