Estoy haciendo un programa que me calcule el periodo de gracia de un prestamo pero no lo e podido lograr.
Este es mi codigo, Cualquier ayuda se los agradeseria mucho:
LoanAmount = Convert.ToDecimal(txtMonto.Text)
LoanIRate = Convert.ToDecimal(txtTasaInteres.Text)
LoanDuration = CInt(txtPlazo.Text)
Montoinicial = LoanAmount
'llama la funsion que calcula el interes mensual
Intrest = Percen.Percentage(LoanIRate)
Payment = (LoanAmount / LoanDuration)
Dim principal, interes, i, p As Double
dtgviewtable.Rows.Clear()
For Period = 1 To LoanDuration
'Pago mensual
IntPmt = (Payment + Intrest)
'calcula el interes
interes = LoanAmount * Intrest
principal = Payment
'calcula el saldo
LoanAmount = LoanAmount - principal
If Val(txtPeriodoGracia.Text) = 3 Then
i = interes * Period
p = Val(txtTasaInteres.Text) * Val(txtMonto.Text)
End If
Dim FechaInicial As Date = Date.Today
'aqui adiciono un mes a la fecha.
FechaInicial = DateAdd("M", Period, Date.Today)
'aqui, me posiciono en el primer dia de la fecha a la que le voy adicionando el mes
FechaInicial = FechaInicial.AddMonths(0)
Dim b As Integer = dtgviewtable.Rows.Add
dtgviewtable.Rows.Item(b).Cells(0).Value = Period
dtgviewtable.Rows.Item(b).Cells(1).Value = (FechaInicial.ToString("D", CultureInfo.CreateSpecificCulture("es-MX")))
dtgviewtable.Rows.Item(b).Cells(2).Value = (Format(Montoinicial, Fmt))
dtgviewtable.Rows.Item(b).Cells(3).Value = (Format(IntPmt, Fmt))
dtgviewtable.Rows.Item(b).Cells(4).Value = (Format(interes, Fmt))
dtgviewtable.Rows.Item(b).Cells(5).Value = (Format(principal, Fmt))
dtgviewtable.Rows.Item(b).Cells(6).Value = (Format(LoanAmount, Fmt))
Next
Perdon se esta un poco enrredado.
Gracias