Option Explicit
Private Sub cmdAzzera_Click()
txtInteresse.Text = ""
txtTermine.Text = ""
txtPagamento.Text = ""
With txtQuantita
.Text = ""
.SetFocus
End With
End Sub
Private Sub cmdCalcola_Click()
On Error GoTo GestioneErrori
'FORMULA = Totale * IntMens
' -------------------------------------------
' (1 - ( 1 / ( 1 + IntMens )) ^ ( Anni * 12 )
Dim IntMens As Single
Dim Quantità As Currency
Dim Numeratore As Currency
Dim Denominatore As Currency
Dim Percento As Single
Dim Totale As Currency
Dim Anni As Integer
Dim Pagamento As Currency
'IntMens = Interesse mensile
Anni = CInt(txtTermine.Text)
Totale = CCur(txtQuantita.Text)
Percento = CSng(txtInteresse.Text) / 100
IntMens = Percento / 12
Numeratore = Totale * IntMens
Denominatore = 1 - (1 / (1 + IntMens)) ^ (Anni * 12)
Pagamento = Numeratore / Denominatore
txtPagamento.Text = Str(Pagamento)
Exit Sub
GestioneErrori:
MsgBox Err.Description, vbExclamation, "ERRORE"
txtQuantita.SetFocus
End Sub
Private Sub cmdEsci_Click()
Unload Me
End Sub
Private Sub Command1_Click()
End Sub
Private Sub cmdEsporta_Click()
frmMain.txtMutuo.Text = txtPagamento.Text
lblEsporta.Caption = "Dato esportato!"
End Sub
Private Sub Form_Deactivate()
lblEsporta.Caption = ""
End Sub