Page 199 - Open Soource Technologies 304.indd
P. 199
Unit 8: Understanding Function and Procedure
Object Property Setting
frmBank Text Bank Deposit
lblAmount Text Amount of bank deposit:
txtAmount
lblRate Text Annual rate of interest:
txtRate
lblNumComp AutoSize False
Text Number of times interest
is compounded per year:
txtNumComp
lblNumYrs Text Number of years:
txtNumYrs
btnCompute Text Compute Balance
lblBalance Text Balance:
txtBalance ReadOnly True
Private Sub btnCompute_Click(...) Handles btnCompute.Click
‘Find the future value of a bank deposit
Dim p As Double ‘principal, the amount deposited
Dim r As Double ‘annual rate of interest
Dim c As Double ‘number of times interest is compounded per year
Dim n As Double ‘number of years
InputData(p, r, c, n)
DisplayBalance(p, r, c, n)
End Sub
Sub InputData(ByRef p As Double, ByRef r As Double, _
ByRef c As Double, ByRef n As Double)
‘Get the four values from the text boxes
p = CDbl(txtAmount.Text)
r = CDbl(txtRate.Text)
c = CDbl(txtNumComp.Text)
n = CDbl(txtNumYrs.Text)
End Sub
Sub DisplayBalance(ByVal p As Double, ByVal r As Double, _
LOVELY PROFESSIONAL UNIVERSITY 193