Listing A Procedure That Uses Multiple ifThen EiseStatements

Function FutureValue3(Rate As Single, Nper As Integer, Pmt As Currency, ^Frequency As String) As Currency If Frequency = "Monthly" Then

FutureValue3 = FV(Rate / 12, Nper * 12, Pmt / 12) ElseIf Frequency = "Quarterly" Then

Else

MsgBox "The Frequency argument must be either " & _ Monthly"" or ""Quarterly""!"

End If End Function

As before, the If...Then statement checks to see whether Frequency equals Monthly and, if it does, calculates the future value accordingly. If it doesn't, the ElseIf...Then statement checks to see whether Frequency equals Quarterly and calculates the future value if the expression returns True. If it returns False, the user entered the Frequency argument incorrectly, so a warning message is displayed.

0 0

Post a comment