I'm trying to make an interest calculator, but when i press the compute button, the total investment box only shows $0.00. What am I doing wrong?
Compute button code
Code:
Private Sub cmdComm_Click()
'Use for loop to calculate a final total
'investment using compound interest.
'
'intNum is a loop control variable
'sngIRate is the annual interest rate
'intTerm is the Number of years in the investment
'curInitInv is the investors initial investment
'sngInterest is the total interest paid
Dim sngIRate As Single, sngInterest As Single
Dim intTerm As Integer, intNum As Integer
Dim curInitInv As Currency
'Error-checking
If ErrorCheck() = 1 Then
Exit Sub
End If
sngIRate = txtIR.Text / 100
intTerm = txtTerm.Text
curInitInv = txtIA.Text
sng = 1 'Begin at first compound
'Use loop to calculate total compound amount
For intNum = 1 To intTerm
sngInterest = sngInterest * (1 + sngIRate)
Next intNum
'Now we have total interest,
'calculate the total investment
'at the end of N years
txtTotal.Text = Format(curInitInv * sngInterest, "$###,##0.00")
End Sub