Hi all! I am in the beginning to mid stages of my project. It's an autobody program. You get the calculations when you click Calculate. However, I can't seem to get the hours of labor box to compute to the correct amount. Whenever I put something more than 1 hour, say 2, you get the same answer as just 1 hour. eg: Parts = $10, Hours of Labor= 2 then when you calculate it, you get just $50. am I making sense? Here is my code so far:

'Program Name:      JobInformation
'Programmer:        xero
'Date:              11/28/2011
'Description:       This program produces a summary of the amounts due for a bill for Pat's Auto Repair Shop.
'                   It incorporates menus, and includes a splah form, a summary form, and an About box form.
'Form:              JobInformation

Option Strict On

Public Class JobInformation
    'Declare projectwide variables.

    Private JobNumberString As String
    Private CustomerNameString As String
    Private CustomerCountInteger As Integer
    Private PartsDecimal As Decimal
    Private HoursOfLaborDecimal As Decimal
    Private HoursOfLaborInteger As Integer

    'Declare module-level variables.
    Private SubTotalDecimal As Decimal
    Private SalesTaxRateDecimal As Decimal
    Private TotalDecimal As Decimal


    'Declare constants.
    Const SALES_TAX_RATE_Decimal As Decimal = 0.08D
    Const HOURS_OF_LABOR_Decimal As Decimal = 50D

    Private Sub CalculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateButton.Click

        ' Calculate and display the current amounts and add to totals.
        ' Declare on the DIM level.

        Dim PartsDecimal As Decimal
        Dim SubTotalDecimal As Decimal
        Dim SalesTaxRateDecimal As Decimal
        Dim TotalDecimal As Decimal
        Dim HoursOfLaborDecimal As Decimal



        'Calculate the extended price and add to job total.
        Try
            PartsDecimal = Decimal.Parse(PartsTextBox.Text)
            SubTotalDecimal = PartsDecimal + HOURS_OF_LABOR_Decimal
            TotalDecimal = SubTotalDecimal + (SALES_TAX_RATE_Decimal * SubTotalDecimal)
            If PartsDecimal > 0 Then
                'Call a function procedure.
                SalesTaxRateDecimal = FindTax(SubTotalDecimal)

            ElseIf HOURS_OF_LABOR_Decimal > 0 Then

                'HoursOfLaborDecimal += HOURS_OF_LABOR_Decimal
                HoursOfLaborDecimal += 1

            Else
                SalesTaxDecimal = 0
            End If

            TotalDecimal = SubTotalDecimal + (SALES_TAX_RATE_Decimal * SubTotalDecimal)
            HoursOfLaborTextBox.Text = HOURS_OF_LABOR_Decimal.ToString("C")
            PartsTextBox.Text = PartsDecimal.ToString("C")
            SubTotalTextBox.Text = SubTotalDecimal.ToString("N")
            SalesTaxRateTextBox.Text = SALES_TAX_RATE_Decimal.ToString("N")
            TotalTextBox.Text = TotalDecimal.ToString("C")

            'Allow clear for new job only.
            ClearButton.Enabled = True

        Catch PartsException As FormatException
            MessageBox.Show("Quantity must be numeric.", "Data entry error",
                            MessageBoxButtons.OK, MessageBoxIcon.Information)
            With PartsTextBox
                .Focus()
                .SelectAll()
            End With

        End Try

    End Sub
    Private Function FindTax(ByVal PartsDecimal As Decimal) As Decimal
        'Calculate the sales tax.

        Return (PartsDecimal * SALES_TAX_RATE_Decimal) + PartsDecimal

    End Function
    


Private Sub JobNumberTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles JobNumberTextBox.TextChanged
        JobNumberString = JobNumberTextBox.Text
End Sub
    

Private Sub CustomerNameTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CustomerNameTextBox.TextChanged
        CustomerNameString = CustomerNameTextBox.Text
End Sub
   
    Private Sub ClearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearButton.Click


        'Clear the appropriate textboxes.

        JobNumberTextBox.Clear()
        CustomerNameTextBox.Clear()
        PartsTextBox.Clear()
        HoursOfLaborTextBox.Clear()
        SubTotalTextBox.Clear()
        SalesTaxRateTextBox.Clear()
        TotalTextBox.Clear()
        With JobNumberTextBox
            .Clear()
            .Focus()

        End With

        PartsDecimal = 0
        HoursOfLaborDecimal = 0
        SubTotalDecimal = 0
        SalesTaxDecimal = 0
        TotalDecimal = 0



    End Sub



    Private Sub OKButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OKButton.Click
        Me.Close()
    End Sub
End Class

I can't actually see where you use the entered hours of labour. You use the constant version here:

SubTotalDecimal = PartsDecimal + HOURS_OF_LABOR_Decimal

And later you have this:

ElseIf HOURS_OF_LABOR_Decimal > 0 Then

The whole idea of a constant is just that - it never changes. So having a test to see if it is over a certain value is really quite pointless.

And then you have this:

HoursOfLaborTextBox.Text = HOURS_OF_LABOR_Decimal.ToString("C")

You never seem to use the HoursofLaborDecimal you set up, except to increment by one during the pointless constant check I pointed out above. I think you confused yourself by having a constant and a variable so closely named.

thanks for the tip, it's working now. I just had to use different names. Now I am working on the summary form.

Mark as solved:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.