Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In visual basics windows design. I want the sales tax to keep adding together wh

ID: 3603015 • Letter: I

Question

In visual basics windows design. I want the sales tax to keep adding together when I add another item to the order. I also want the total to add together.this is my code so far


'this line calculates the subtotal before taxes and shipping

sngSubTotal = sngQuantity * msngQuiltCost
'this line calculates the sales tax based on the tax rate constant
sngSalesTax = sngSubTotal * CSngSalesTax

'this line caluclates the total for the order
sngTotal = sngSubTotal + sngSalesTax + msngShipping


msngSubTotal += sngSubTotal

Explanation / Answer

Option Strict On Public Class Form1 Dim OrderLines As List(Of OrderLine) = New List(Of OrderLine) Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click Dim intQuantity As Integer If Not Integer.TryParse(txtQuantity.Text, intQuantity) Then MsgBox("Error in entering quantity") Exit Sub End If Dim decPrice As Decimal If Not Decimal.TryParse(txtPrice.Text, decPrice) Then MsgBox("Error in entering price") Exit Sub End If Dim decTotal As Decimal = decPrice * CDec(intQuantity) txtTotal.Text = decTotal.ToString OrderLines.Add(New OrderLine(txtItem.Text, intQuantity, decPrice)) ListUpdate() End Sub Private Sub ListUpdate() ListBox1.Items.Clear() For Each O As OrderLine In OrderLines ListBox1.Items.Add(O.ToString) Next End Sub Private Structure OrderLine Dim LineItem As String Dim LineQuantity As Integer Dim LinePrice As Decimal Public Sub New(ByVal Item As String, ByVal Quantity As Integer, ByVal Price As Decimal) LineItem = Item LineQuantity = Quantity LinePrice = Price End Sub Public Overloads Function ToString() As String Return LineItem & " " & LinePrice.ToString _ & " " & LineQuantity.ToString _ & " " & (LinePrice * CDec(LineQuantity)).ToString End Function End Structure End Class

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote