Adding totals from CheckBox Controls and display in labels

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RodPhp5
    New Member
    • Apr 2013
    • 4

    #1

    Adding totals from CheckBox Controls and display in labels

    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.

    Code:
    Private Sub CalcButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalcButton.Click
            'declaring local variables
            Dim sngBasePrice, sngAllowancePrice, msngSubTotal, sngSalesTax, _
            sngTotalPrice, sngGrandTotal As Single
            Dim sngStereo, sngLeather, sngNavigation, sngStandard, sngPearlized, _
            sngCustomized, sngTaxRate As Single
            sngStereo = 425.76
            sngLeather = 987.41
            sngNavigation = 1741.23
            sngPearlized = 345.72
            sngCustomized = 599.99
            sngTaxRate = 0.08
            'assigning values to variables
            sngBasePrice = Val(Me.BasePriceTextBox.Text)
            sngAllowancePrice = Val(Me.TradeInAllowanceTextBox.Text)
            'checking which TexBox was clicked, and adding neccesary amount
            Select Case True
                Case Me.StereoCheckBox.Checked
                    msngSubTotal = sngStereo + sngBasePrice
                Case Me.LeatherCheckBox.Checked
                    msngSubTotal = sngLeather + sngBasePrice
                Case Me.NavigationCheckBox.Checked
                    msngSubTotal = sngNavigation + sngBasePrice
                Case Me.StandardCheckBox.Checked
                    msngSubTotal = sngStandard + sngBasePrice
                Case Me.PearlizedCheckBox.Checked
                    msngSubTotal = sngPearlized + sngBasePrice
                Case Me.CustomizedCheckBox.Checked
                    msngSubTotal = sngCustomized + sngBasePrice
                Case Else 'calculations
                    msngSubTotal = sngBasePrice
                    sngSalesTax = msngSubTotal * sngTaxRate
                    sngTotalPrice = msngSubTotal + sngSalesTax
                    sngGrandTotal = sngTotalPrice - sngAllowancePrice
                    'display the total amounts in label controls
                    Me.SubTotalLabel.Text = msngSubTotal
                    Me.TotalPriceLabel.Text = sngSalesTax
                    Me.AmountDueLabe.Text = sngGrandTotal
            End Select
        End Sub
    End Class
Working...