Find the total cost, Visual Basic Programming

Assignment Help:

<HTML>

<H2> Case: Design a web page that contains the VBScript utilized for calculating subtotals, taxes, discounts & totals as well as code utilized to validate user input.</H2>

<HEAD>

<TITLE>VBScript: Case Study</TITLE>

<SCRIPT LANGUAGE="VBScript">

<!-- Add this to instruct non-IE browsers to skip over VBScript modules. Option Explicit

Sub cmd Calculate_On Click Dim Amount of Discount Dim Amount of Tax

Dim DISCOUNT_LIMIT Dim DISCOUNT_RATE Dim Subtotal Before

Dim Subtotal After Dim TAX_RATE Dim Total Cost

 

If (Len(Document .frmCaseStudy.txtQuantity.Value) = 0) Then

MsgBox "You have to enter quantity." Exit Sub

End If

If (Not IsNumeric(Document.frmCaseStudy.txtQuantity.Value)) Then

MsgBox "Quantity has to be a numeric value." Exit Sub

End If

If (Len(Document.frmCaseStudy.cmbProducts.Value) = 0) Then

MsgBox "You have to select product." Exit Sub

End If

DISCOUNT_LIMIT = 1000

DISCOUNT_RATE = .10

TAX_RATE = 0.06

'Calculate the subtotal for the order.

SubtotalBefore=Document.frmCaseStudy.txtQuantity.Value* Document.frmCaseStudy.lblUnitCost.value

If (SubtotalBefore > DISCOUNT_LIMIT) Then

AmountofDiscount = SubtotalBefore * DISCOUNT_RATE Else

AmountofDiscount = 0

End If

SubtotalAfter = SubtotalBefore - AmountofDiscount

' Calculate taxes & total cost.

AmountofTax = SubtotalAfter * TAX_RATE TotalCost = SubtotalAfter + AmountofTax

'Display the results. Document.frmCaseStudy.lblSubtotalBefore.value = SubtotalBefore Document.frmCaseStudy.lblDiscount.value=AmountofDiscount Document.frmCaseStudy.lblSubtotalAfter.value=SubtotalAfter Document.frmCaseStudy.lblTaxes.value=AmountofTax Document.frmCaseStudy.lblTotalCost.value = TotalCost

 

End Sub

Sub cmdSubmit_onClick

'Submit this order for processing.

MsgBox "Your order has been submitted." Document.frmCaseStudy.Submit

End Sub

Sub cmbProducts_onchange()

Select Case Document.frmCaseStudy.cmbProducts.SelectedIndex

Case 1

Document.frmCaseStudy.lblUnitCost.value = 1590

Case 2

Document.frmCaseStudy.lblUnitCost.value = 880

Case 3

Document.frmCaseStudy.lblUnitCost.value = 1940

Case Else

Document.frmCaseStudy.lblUnitCost.value = 0

End Select

End Sub

-->

</SCRIPT>

</HEAD>

<BODY>

<FORM NAME="frmCaseStudy">

<TABLE>

<TR>

<TD><B>Monitor:</B></TD>

<TD>

<SELECT NAME = "cmbProducts">

<OPTION VALUE ="0" ></OPTION>

<OPTION VALUE ="1" >Item 1</OPTION>

<OPTION VALUE ="2">Item 2</OPTION>

<OPTION VALUE ="3">Item 3</OPTION>

</SELECT>

</TD>

</TR>

<TR>

<TD><B>Quantity:</B></TD>

<TD>

<INPUT TYPE = "TEXT" NAME ="txtQuantity" >

</TD>

</TR>

<TR>

<TD><INPUT TYPE="Button" NAME="cmdCalculate" VALUE="Calculate

Cost"></TD>

<TD></TD>

</TR>

<TR>

<TD><B>Unit Cost:</B></TD>

<TD>

<INPUT TYPE = "TEXT" NAME ="lblUnitCost" >

</TD>

</TR>

<TR>

<TD><B>Subtotal before discount:</B></TD>

<TD>

<INPUT TYPE = "TEXT" NAME ="lblSubtotalBefore" >

</TD>

</TR>

<TR>

<TD><B>Discount:</B></TD>

<TD>

<INPUT TYPE = "TEXT" NAME = "lblDiscount" >

</TD>

</TR>

<TR>

<TD><B>Subtotal after discount:</B></TD>

<TD>

<INPUT TYPE = "TEXT" NAME ="lblSubtotalAfter" >

</TD>

</TR>

<TR>

<TD><B>Taxes:</B></TD>

<TD>

<INPUT TYPE = "TEXT" NAME ="lblTaxes" >

</TD>

</TR>

<TR>

<TD><B>Total Cost:</B></TD>

<TD>

<INPUT TYPE = "TEXT" NAME ="lblTotalCost" >

</TD>

</TR>

<TR>

<TD><INPUT TYPE="Button" NAME="cmdSubmit" VALUE="Submit

Order"></TD>

<TD></TD>

</TR>

</TABLE>

</FORM>

</BODY>

</HTML>


Related Discussions:- Find the total cost

Object naming conventions, The following table lists suggested conventions ...

The following table lists suggested conventions for objects you might encounter while programming VBScript. Code Commenting Conventions All process should begin with a brie

Investment loan program, I have all my program done except the loan part th...

I have all my program done except the loan part that I am having a lot of troubles with

Retrieval methods - document in visual programming, Retrieval Methods: ...

Retrieval Methods: There are 3 ways to find a document. The primary method is a positional retrieval. This is achieved by keeping in mind where you left it. The next method is

Resources - visual basic programming, RESOURCES The cursors, Icons, dia...

RESOURCES The cursors, Icons, dialog, bitmaps accelerators, menu, table tool bar and string are the different resources. The resources are compiled by the resource compiler. Th

To calculate rectangle, two sides are given of a sheet e.g 23*36 i want hal...

two sides are given of a sheet e.g 23*36 i want half or 1/2 of this sheet next i want 1/4(one fourth) of this sheet if sheet size is 23*36 next i want 1/8 similary as above

Events - intrinsic contol, Events: The Controls are placed on a form a...

Events: The Controls are placed on a form and then to make them functional an "event procedure" is related with the control object. An event process is what happens in respons

program that compares interest rates between two banks, 'This program comp...

'This program compares interest rates between two banks and determines the best bank PublicClassForm1 PrivateSub Button1_Click(sender AsSystem.Object, e AsSystem.EventArgs) H

Mfc classes, THE MFC CLASSES The CDocument, CWinAppCFrameWnd and CView ...

THE MFC CLASSES The CDocument, CWinAppCFrameWnd and CView are derived from the CObject and they give the majority of the structure and functionality.

Restricting the vocabulary - visual interface design, Restricting The Vocab...

Restricting The Vocabulary: The properly formed vocabulary is like an inverted pyramid. All easy to learn communication system follow this pattern. The canonical vocabulary in

Running statements if a condition is true, To run only one statement while ...

To run only one statement while a condition is True, employ the single-line syntax for the If...Then...Else statement. The following instance shows the single-line syntax. Notice t

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd