By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,333 Members | 1,047 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,333 IT Pros & Developers. It's quick & easy.

Adding totals from CheckBox Controls and display in labels

P: 4
I need help on this im stuck...

I am supposed to add price of the selected accessories and exterior finish if they have been checked, and display the result in Subtotal. Calculate sales tax on subtotal and display the result in Total label, and finally subract the trade-in allowance from the Total label to get Amount due. I have developed the code but my problem is that when i check the checkboxes the totals are not displayed, but if i dont check the checkboxes the totals are displayed.

Expand|Select|Wrap|Line Numbers
  1. Private Sub CalcButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalcButton.Click
  2.         'declaring local variables
  3.         Dim sngBasePrice, sngAllowancePrice, msngSubTotal, sngSalesTax, _
  4.         sngTotalPrice, sngGrandTotal As Single
  5.         Dim sngStereo, sngLeather, sngNavigation, sngStandard, sngPearlized, _
  6.         sngCustomized, sngTaxRate As Single
  7.         sngStereo = 425.76
  8.         sngLeather = 987.41
  9.         sngNavigation = 1741.23
  10.         sngPearlized = 345.72
  11.         sngCustomized = 599.99
  12.         sngTaxRate = 0.08
  13.         'assigning values to variables
  14.         sngBasePrice = Val(Me.BasePriceTextBox.Text)
  15.         sngAllowancePrice = Val(Me.TradeInAllowanceTextBox.Text)
  16.         'checking which TexBox was clicked, and adding neccesary amount
  17.         Select Case True
  18.             Case Me.StereoCheckBox.Checked
  19.                 msngSubTotal = sngStereo + sngBasePrice
  20.             Case Me.LeatherCheckBox.Checked
  21.                 msngSubTotal = sngLeather + sngBasePrice
  22.             Case Me.NavigationCheckBox.Checked
  23.                 msngSubTotal = sngNavigation + sngBasePrice
  24.             Case Me.StandardCheckBox.Checked
  25.                 msngSubTotal = sngStandard + sngBasePrice
  26.             Case Me.PearlizedCheckBox.Checked
  27.                 msngSubTotal = sngPearlized + sngBasePrice
  28.             Case Me.CustomizedCheckBox.Checked
  29.                 msngSubTotal = sngCustomized + sngBasePrice
  30.             Case Else 'calculations
  31.                 msngSubTotal = sngBasePrice
  32.                 sngSalesTax = msngSubTotal * sngTaxRate
  33.                 sngTotalPrice = msngSubTotal + sngSalesTax
  34.                 sngGrandTotal = sngTotalPrice - sngAllowancePrice
  35.                 'display the total amounts in label controls
  36.                 Me.SubTotalLabel.Text = msngSubTotal
  37.                 Me.TotalPriceLabel.Text = sngSalesTax
  38.                 Me.AmountDueLabe.Text = sngGrandTotal
  39.         End Select
  40.     End Sub
  41. End Class
  42.  
Aug 10 '13 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.