Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Public Class frmInvoiceTotal Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click 'Dim subtotal As Decimal = CDec(txtSubtotal.Text) Dim subtotal As Decimal = Decimal.Parse(txtSubtotal.Text)

Public Class frmInvoiceTotal Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click

'Dim subtotal As Decimal = CDec(txtSubtotal.Text)

Dim subtotal As Decimal = Decimal.Parse(txtSubtotal.Text)

Dim discountPercent As Decimal

If subtotal >= 500 Then discountPercent = 0.2D ElseIf subtotal >= 250 And Subtotal < 500 Then discountPercent = 0.15D ElseIf subtotal >= 100 And Subtotal < 250 Then discountPercent = 0.1D Else discountPercent = 0 End If

Dim discountAmount As Decimal = subtotal * discountPercent

Dim invoiceTotal As Decimal = subtotal - discountAmount

'txtDiscountPercent.Text = FormatPercent(discountPercent, 2)

txtDiscountAmount.Text = FormatCurrency(discountAmount, 2)

txtTotal.Text = FormatCurrency(invoiceTotal, 2)

txtDiscountPercent.Text = discountPercent.ToString("p2") txtDiscountAmount.Text = discountAmount.ToString("c2") txtTotal.Text = invoiceTotal.ToString("c2")

txtSubtotal.Select() End Sub

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click Me.Close() End Sub End Class

In visual Studio, In this code,

Explain the CDec function,

Dim subtotal As Decimal = CDec(txtSubtotal.Text)

and

the Decimal Parse method

Dim subtotal As Decimal = Decimal.Parse(txtSubtotal.Text)

comment to explain the statement Discount Percent, discountAmount and invoicetotal format as following:

txtDiscountPercent.Text = FormatPercent(discountPercent, 2)

txtDiscountAmount.Text = FormatCurrency(discountAmount, 2)

txtTotal.Text = FormatCurrency(invoiceTotal, 2)

And comment to explain the ToString method for discountPercent, discountAmount and invoiceTotal.

txtDiscountPercent.Text = discountPercent.ToString("p2") txtDiscountAmount.Text = discountAmount.ToString("c2") txtTotal.Text = invoiceTotal.ToString("c2")

Explain those statements which are in this code. Do not give general statement, Stay in the code and explain it as a statement in this code Please.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions

Question

1. Explain how new technologies are influencing training.

Answered: 1 week ago