Question
I need visual basic code for the following question. In this exercise, youll add a second form to an Invoice Total application that lets the
I need visual basic code for the following question. In this exercise, youll add a second form to an Invoice Total application that lets the user change the sales tax percent. i need help changeing the sales tax and then display the sales tax back in form 1 and the caculate for the new total. heres what I have so far. I need Public Class Form1 Const SalesTaxPct As Decimal = 7.75D Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click If IsValidData() Then Dim productTotal As Decimal = Convert.ToDecimal(txtProductTotal.Text) Dim discountPercent As Decimal = 0D If productTotal < 100 Then discountPercent = 0D ElseIf productTotal >= 100 AndAlso productTotal < 250 Then discountPercent = 0.1D ElseIf productTotal >= 250 Then discountPercent = 0.25D End If Dim discountAmount As Decimal = productTotal * discountPercent Dim subtotal As Decimal = productTotal - discountAmount Dim tax As Decimal = subtotal * SalesTaxPct / 100 Dim total As Decimal = subtotal + tax txtDiscountAmount.Text = FormatCurrency(discountAmount) txtSubtotal.Text = FormatCurrency(subtotal) txtTax.Text = FormatCurrency(tax) txtTotal.Text = FormatCurrency(total) End If End Sub Public Function IsValidData() As Boolean Return IsPresent(txtProductTotal, "Subtotal") AndAlso IsDecimal(txtProductTotal, "Subtotal") AndAlso IsWithinRange(txtProductTotal, "Subtotal", 0, 1000000) End Function Public Function IsPresent(textBox As TextBox, name As String) As Boolean If textBox.Text = "" Then MessageBox.Show(name & " is a required field.", "Entry Error") textBox.Select() Return False End If Return True End Function Public Function IsDecimal(textBox As TextBox, name As String) As Boolean Dim number As Decimal = 0 If Decimal.TryParse(textBox.Text, number) Then Return True Else MessageBox.Show(name & " must be a decimal number.", "Entry Error") textBox.Select() textBox.SelectAll() Return False End If End Function Public Function IsWithinRange(textBox As TextBox, name As String, min As Decimal, max As Decimal) As Boolean Dim number As Decimal = Convert.ToDecimal(textBox.Text) If number <= min OrElse number >= max Then MessageBox.Show(name & " must be between " & min & " and " & max & ".", "Entry Error") textBox.Select() textBox.SelectAll() Return False End If Return True End Function Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click Me.Close() End Sub Private Sub btnChgPercent_Click(sender As Object, e As EventArgs) Handles btnChgPercent.Click Sales_Tax.Show() End Sub End Class Public Class Sales_Tax Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click Form1.Show() TextBox1.Text = Form1.txtTax.Text End Sub End Class
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started