Public Class Form1
Private Sub btnPago_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPago.Click
Dim C, i, n, p As Double
C = txtCapital.Text
i = txtInteres.Text / 100
n = txtPeridos.Text
'p = C * ((i * Math.Pow((1 + i), n) / (Math.Pow((1 + i), n) - 1)))
'txtPago.Text = p.ToString("#,##0.00")
'btnTabla.Enabled = True
End Sub
Private Sub btnTabla_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTabla.Click
'Disparar la funcion CalcularCelda al cambiar el valor de la celda
DataGridView1.ColumnCount = 8 'Tres Columnas
DataGridView1.RowCount = txtPeridos.Text ' Numero de Periodos
DataGridView1.AllowUserToAddRows = False 'Sin opcion añadir filas
For i = 0 To (CInt(txtPeridos.Text) - 1)
With DataGridView1
If i = 0 Then
'Columna Cuotas
.Rows(i).Cells(0).Value = i + 1
'Columna Fecha de Pago
.Rows(i).Cells(1).Value = Format(CDate(DateTimePicker1.Text), "Short Date")
'Columna Numeros de días
.Rows(i).Cells(5).Value = DateDiff(DateInterval.Day, CDate(DateTimePicker2.Value.ToString("dd/MM/yy")), CDate(DataGridView1.Rows(i).Cells(1).Value))
'Columna Deslizamiento
.Rows(i).Cells(3).Value = Format(CDbl(txtCapital.Text) * (0.06 / 12 / 30) * CDbl(.Rows(i).Cells(5).Value), "#,##0.00")
'Columna Interes
.Rows(i).Cells(4).Value = Format(((CDbl(txtCapital.Text) + CDbl(.Rows(i).Cells(3).Value)) * (CDbl(txtInteres.Text) / 100) * CDbl(.Rows(i).Cells(5).Value)) / 30, "#,##0.00")
'Total a Pagar
.Rows(i).Cells(6).Value = Format(CDbl(txtPago.Text), "#,##0.00")
'Columna Abono