pouncer
February 10th, 2009, 02:32 PM
Dim LoanAmount As Decimal
Dim MonthlyPayment As Decimal
Dim IntrestRate As Decimal
Dim Counter As Integer
Dim Balance As Decimal
lblMsg.Text = ""
If IsNumeric(txtLoanAmount.Text) Then
If txtLoanAmount.Text > 0 Then
If IsNumeric(txtMonthlyRePayment.Text) Then
If txtMonthlyRePayment.Text > 0 Then
LoanAmount = txtLoanAmount.Text
MonthlyPayment = txtMonthlyRePayment.Text
IntrestRate = cboIntrestRate.Text
Balance = LoanAmount
Counter = 1
Do While Balance >= 0
Balance = LoanAmount - MonthlyPayment + (LoanAmount * IntrestRate)
LoanAmount = Balance
If Balance >= 0 Then
lstPaymentSchedule.Items.Add("Month " & Counter & " Balance is £" & Math.Round(Balance, 2))
Else
lstPaymentSchedule.Items.Add("Month " & Counter & " Balance is £0.00")
End If
Counter += 1
Loop
Else
lblMsg.Text = "Please enter a value bigger then 0"
End If
Else
lblMsg.Text = "Please enter a valid Monthly Repaymment"
End If
Else
lblMsg.Text = "Please enter a value greater than 0"
End If
Else
lblMsg.Text = "Please enter a valid Loanamount"
End If
End Sub
Then interface is like
Loan amount : ______ (user puts in data)
Monthly repay: ______ (user puts in data)
Intrest rate: ______ (user selects 0.001, 0.002. 0.003. 0.004)
Payment sched:
Month 1 balance =
month 2 balance =
etc
Everything works fine
just got a problem with few amounts e.g
If user puts in
Loan amount: 10000
Month repy: 1
intrest rate: 0.001
program crashes and says
Value was either too large or too small for a Decimal. (Pointing at the Monthly repayment.
ow can i get round dis
Thanks in advance!
Dim MonthlyPayment As Decimal
Dim IntrestRate As Decimal
Dim Counter As Integer
Dim Balance As Decimal
lblMsg.Text = ""
If IsNumeric(txtLoanAmount.Text) Then
If txtLoanAmount.Text > 0 Then
If IsNumeric(txtMonthlyRePayment.Text) Then
If txtMonthlyRePayment.Text > 0 Then
LoanAmount = txtLoanAmount.Text
MonthlyPayment = txtMonthlyRePayment.Text
IntrestRate = cboIntrestRate.Text
Balance = LoanAmount
Counter = 1
Do While Balance >= 0
Balance = LoanAmount - MonthlyPayment + (LoanAmount * IntrestRate)
LoanAmount = Balance
If Balance >= 0 Then
lstPaymentSchedule.Items.Add("Month " & Counter & " Balance is £" & Math.Round(Balance, 2))
Else
lstPaymentSchedule.Items.Add("Month " & Counter & " Balance is £0.00")
End If
Counter += 1
Loop
Else
lblMsg.Text = "Please enter a value bigger then 0"
End If
Else
lblMsg.Text = "Please enter a valid Monthly Repaymment"
End If
Else
lblMsg.Text = "Please enter a value greater than 0"
End If
Else
lblMsg.Text = "Please enter a valid Loanamount"
End If
End Sub
Then interface is like
Loan amount : ______ (user puts in data)
Monthly repay: ______ (user puts in data)
Intrest rate: ______ (user selects 0.001, 0.002. 0.003. 0.004)
Payment sched:
Month 1 balance =
month 2 balance =
etc
Everything works fine
just got a problem with few amounts e.g
If user puts in
Loan amount: 10000
Month repy: 1
intrest rate: 0.001
program crashes and says
Value was either too large or too small for a Decimal. (Pointing at the Monthly repayment.
ow can i get round dis
Thanks in advance!