Programming for Everybody: With source code- Visual Basic.net project: System calculate installments and due dates in VB.net

With source code- Visual Basic.net project: System calculate installments and due dates in VB.net


Public Class Form5
    Dim dt As New DataTable
    Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        dt.Columns.Add("Installment", GetType(String))
        dt.Columns.Add("Value", GetType(Integer))
        dt.Columns.Add("Due_date", GetType(Date))
        DataGridView1.DataSource = dt
        
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim price_v, adv_payment, installment_value, n_intallments, final_installment As Double
        price_v = TextBox1.Text
        adv_payment = TextBox2.Text
        installment_value = TextBox3.Text
        n_intallments = Math.Ceiling((price_v - adv_payment) / installment_value)
        final_installment = (price_v - adv_payment) Mod installment_value
        DataGridView1.DataSource = Nothing
        dt.Clear()
        DataGridView1.DataSource = dt
        DataGridView1.Columns("Due_date").DefaultCellStyle.Format = "MM-dd-yyyy"
        For i As Integer = 1 To n_intallments
            Dim date_payment = DateAdd(DateInterval.Month, i, Now)
            dt.Rows.Add("Installment" & i, TextBox3.Text, date_payment)
        Next
        If final_installment <> 0 Then
            Dim lastrow As Integer = DataGridView1.Rows.Count - 1
            DataGridView1.Rows(lastrow).Cells(1).Value = final_installment
        End If

    End Sub 

No comments:

Post a Comment