Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

VS 02/03 [RESOLVED] Code Question Visual Studio 2010

$
0
0
Not sure if this is the right place but here is my issue. My function "SalesTax" is only supposed to return the cost of sales tax on parts. The function "OtherCharges" covers both parts and labor so what do I need to revise in my code to make the "SalesTax" function only do that? I have a general idea as you can see in the code below and I am sure its something simple im missing. Any help would be much appreciated.


Code:

Public Class Form1
    Const dblOIL_COST As Double = 26.0
    Const dblLUBE_COST As Double = 18.0
    Const dblINSPECTION_COST As Double = 15.0
    Const dblREPLACE_MUFFLER As Double = 100.0
    Const dblTIRE_ROTATION As Double = 20.0
    Const dblRAD_FLUSH As Double = 30.0
    Const dblTRANNY_FLUSH As Double = 80.0
    Const dblSALES_TAX As Double = 0.06
    'Const dblLABOR_RATE As Double = 20.0

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

    Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
        lblService = OilLubeCharges() + FlushCharges() + MiscCharges() + OtherCharges()
        lblParts = OtherCharges()
        lblTax = TaxCharges()
        lblTotal = OilLubeCharges() + FlushCharges() + MiscCharges() + OtherCharges() + TaxCharges()
    End Sub

    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        'clear check boxes
        ClearOilLube()
        ClearFlushes()
        ClearMisc()
        'clear text boxes
        ClearOther()
        'clear labels
        ClearFees()
    End Sub

    Function OilLubeCharges() As Double
        Dim dblOilLubeCharges As Double

        If chkOilChange.Checked = True Then
            dblOilLubeCharges += dblOIL_COST
        End If
        If chkLubeJob.Checked = True Then
            dblOilLubeCharges += dblLUBE_COST
        End If

        Return dblOilLubeCharges
    End Function

    Function FlushCharges() As Double
        Dim dblFlushCharges As Double

        If chkRadFlush.Checked = True Then
            dblFlushCharges += dblRAD_FLUSH
        End If
        If chkTrannyFlush.Checked = True Then
            dblFlushCharges += dblTRANNY_FLUSH
        End If

        Return dblFlushCharges
    End Function

    Function MiscCharges() As Double
        Dim dblMiscCharges As Double

        If chkInspection.Checked = True Then
            dblMiscCharges += dblINSPECTION_COST
        End If
        If chkReplaceMuffler.Checked = True Then
            dblMiscCharges += dblREPLACE_MUFFLER
        End If
        If chkTireRotation.Checked = True Then
            dblMiscCharges += dblTIRE_ROTATION
        End If

        Return dblMiscCharges
    End Function

    Function OtherCharges(ByVal dblPartCost As Double, ByVal dblLaborCost As Double) As Double
        Dim dblOtherCharges As Double

        If Double.TryParse(txtParts.Text, dblPartCost) Then
            If dblPartCost >= 0 Then
                If Double.TryParse(txtLabor.Text, dblLaborCost) Then
                    If dblLaborCost >= 0 Then

                        dblOtherCharges += dblPartCost
                        dblOtherCharges += dblLaborCost

                    Else : MessageBox.Show("Labor cost must be a value of 0 or greater.", "Input error", MessageBoxButtons.OK, MessageBoxIcon.Hand)
                    End If
                Else : MessageBox.Show("Labor cost must be an integer value.", "Input error", MessageBoxButtons.OK, MessageBoxIcon.Hand)
                End If
            Else : MessageBox.Show("Part cost must be a value of 0 or greater.", "Input error", MessageBoxButtons.OK, MessageBoxIcon.Hand)
            End If
        Else : MessageBox.Show("Part cost must be an integer value.", "Input error", MessageBoxButtons.OK, MessageBoxIcon.Hand)
        End If

        Return dblOtherCharges
        'Return dblLaborCost
        'Return dblPartCost
    End Function

    Function TaxCharges(ByVal dblTaxCharges As Double) As Double

        Return dblTaxCharges * dblSALES_TAX

    End Function

    Sub ClearOilLube()
        chkOilChange.Checked = False
        chkLubeJob.Checked = False
    End Sub

    Sub ClearFlushes()
        chkRadFlush.Checked = False
        chkTrannyFlush.Checked = False
    End Sub

    Sub ClearMisc()
        chkInspection.Checked = False
        chkReplaceMuffler.Checked = False
        chkTireRotation.Checked = False
    End Sub

    Sub ClearOther()
        txtLabor.Clear()
        txtParts.Clear()
    End Sub

    Sub ClearFees()
        lblParts.Text = String.Empty
        lblService.Text = String.Empty
        lblTax.Text = String.Empty
        lblTotal.Text = String.Empty
    End Sub

    Private Function dblTaxAmount() As Object
        Throw New NotImplementedException
    End Function

    Private Function OtherCharges(ByVal p1 As Object) As Double
        Throw New NotImplementedException
    End Function

End Class


Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>