|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
I am supposed to build a Cash Register Application using Select Case statement. The Sales Tax needs to be calculated for the
amount purchased. I am supposed to add the sales tax to the subtotal and add the subtotal to the total. The Select Case statement was used to enter the TaxRate and I think I am supposed to multiply the TaxRate by the TaxValue. I am having trouble with the button Enter key and the button Total key. When I enter a number such as $25.00, the $25.00 will show up in the subtotal, but when I enter $25.00 again it freezes up. Please help. I am new to VB and I really do not know what the heck I am doing. ' Private Sub txtCurrentPrice_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtCurrentPrice.TextChanged '(I DO NOT KNOW WHAT THIS HANDLER IS SUPPOSED TO DO) ' End Sub PrivateSub btnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnter.Click 'This handler is supposed to add the current amount to the subtotal and display new 'subtotal. Dim sngCurrentPrice AsSingle sngCurrentPrice = Val(txtCurrentPrice.Text) Dim sngSubtotalValue AsSingle sngSubtotalValue = Val(lblSubtotalValue.Text) Dim sngTaxValue AsSingle sngTaxValue = Val(lblTaxValue.Text) sngSubtotalValue += sngCurrentPrice txtCurrentPrice.Text = "" lblSubtotalValue.Text = String.Format("{0:C}", sngSubtotalValue) EndSub'btnEnter_Click PrivateSub btnTotal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTotal.Click 'This handler is supposed to use the subtotal to compute the tax amount. Dim sngCurrentPrice AsSingle sngCurrentPrice = Val(txtCurrentPrice.Text) Dim sngSubtotalValue AsSingle sngSubtotalValue = Val(lblSubtotalValue.Text) Dim sngTaxValue AsSingle sngTaxValue = Val(lblTaxValue.Text) Dim decTaxRate AsString SelectCase sngCurrentPrice 'amounts under $100 CaseIs < 100 decTaxRate = 0.05 'Sales Tax 'amounts between $100 and $500 Case 100 To 500 decTaxRate = 0.075 'sales tax 'amounts above $500 CaseIs > 500 decTaxRate = 0.1 'sales tax 'if no other case is true CaseElse decTaxRate = 0.0 'sales tax EndSelect 'lblTaxValue.Text = strTaxRate Dim dblTotalValue AsDouble dblTotalValue = Val(lblTotalValue.Text) lblTaxValue.Text = decTaxRate 'sngTaxValue += sngSubtotalValue 'dblTotalValue = sngSubtotalValue + decTaxRate 'dblTotalValue = sngSubtotalValue + (sngCurrentPrice * decTaxRate) 'or dblTotalValue = dblTotalValue + (sngCurrentPrice * decTaxRate) lblSubtotalValue.Text = String.Format("{0:C}", sngSubtotalValue) lblTaxValue.Text = String.Format("{0:C}", sngTaxValue) EndSub'btnTotal_Click |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Need help with Cash Register Application in VB.NET |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|