Page 200 - Open Soource Technologies 304.indd
P. 200
Event Driven Programming
ByVal c As Double, ByVal n As Double)
‘Display the balance in a text box
Dim balance As Double
balance = FutureValue(p, r, c, n)
txtbalance.Text = FormatCurrency(balance)
End Sub
function FutureValue(ByVal p As Double, ByVal r As Double, _
ByVal c As Double, ByVal n As Double) As Double
‘Find the future value of a bank savings account
‘p principal, the amount deposited
‘r annual rate of interest
‘c number of times interest is compounded per year
‘n number of years
Dim i As Double ‘interest rate per period
Dim m As Double ‘total number of times interest is compounded
i = r / c
m = c * n
Return p * ((1 + i) ^ m)
End function
[Run, type 100, .04, 4, and 5 into the text boxes, then click the button.]
Questions
1. What is the difference between Msgbox Statement and MsgboxQ function?
2. Write a visual Basic program for modules.
194 LOVELY PROFESSIONAL UNIVERSITY