0% found this document useful (0 votes)
15 views

Visual Basic - Ejercicio

This code calculates order totals for a form with a datagrid. It loops through rows, calculates subtotals and discounts, and sums the subtotals, discounts, taxes, and total. The subtotal is calculated by multiplying quantity and price cells. If the subtotal is over $100, a 10% discount is applied. Subtotals, discounts, taxes, and total are summed and displayed in textboxes.

Uploaded by

crisurgiles
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Visual Basic - Ejercicio

This code calculates order totals for a form with a datagrid. It loops through rows, calculates subtotals and discounts, and sums the subtotals, discounts, taxes, and total. The subtotal is calculated by multiplying quantity and price cells. If the subtotal is over $100, a 10% discount is applied. Subtotals, discounts, taxes, and total are summed and displayed in textboxes.

Uploaded by

crisurgiles
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Public Class Form3 Private Sub btncalcular_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncalcular.

Click Dim Subtotal As Double Dim Desc As Double Dim f, i As Integer Dim St As Double Dim Ds As Double Dim iva As Double Dim Total As Double f = dgvmatriz.RowCount - 2 St = 0 Ds = 0 For i = 0 To f Subtotal = dgvmatriz(1, i).Value * dgvmatriz(2, i).Value dgvmatriz(3, i).Value = Subtotal If Subtotal >= 100 Then Desc = Subtotal * 0.1 dgvmatriz(4, i).Value = Desc Else dgvmatriz(4, i).Value = 0 End If

St = St + dgvmatriz(3, i).Value Ds = Ds + dgvmatriz(4, i).Value iva = (St - Desc) * 0.12 Total = (St - Desc) + iva Next txtdescuento.Text = Ds txtsubtotal.Text = St txtiva.Text = iva txttotal.Text = Total End Sub End Class

You might also like