I am testing my program "Pats Auto Repair shop" that includes the mainform with menustrips for file, process and help, Splash form, About, Job information form and summary form. The process has two subs, job information with a separator for "summary", and summary form.

I written all coding solutions for the 3 forms (Main, Job, Summary). When pressing the calculate button on the job form I get a data error. Can someone take a look and see where I went wrong?

Recommended Answers

All 2 Replies

Just posting all this code isn't too helpful. Please also post the errors you are getting.

In the event handler for the CalculateButton.Click event you're parsing raw data without checking if it's valid. you will find much better success by initializing the decimal variables to 0 and parsing the textboxes with TryParse. If it succeeds the variable will have a new value. If not it will have 0. Also since your data is now more robust I would suggest that you can do away with the Try block, which isn't really being used properly in the first place:

    Dim PartsDecimal As Decimal = 0
    Dim SubTotalDecimal As Decimal = 0
    Dim SalesTaxRateDecimal As Decimal = 0
    Dim TotalDecimal As Decimal = 0
    Dim LaborTotalDecimal As Decimal = 0
    Dim LaborHoursDecimal As Decimal = 0
    Dim PartsAmtDecimal As Decimal = 0

    'Calculate the extended price and add to job total.'
    Decimal.TryParse(PartsTextBox.Text, PartsDecimal)
    Decimal.TryParse(PartsAmtTextBox.Text, PartsAmtDecimal)
    Decimal.TryParse(LaborHoursTextBox.Text, LaborHoursDecimal)
    Decimal.TryParse(HoursOfLaborTextBox.Text, LaborTotalDecimal)
    SubTotalDecimal = PartsDecimal + LABOR_COST_Decimal * HoursOfLaborDecimal
    TotalDecimal = SubTotalDecimal + (SALES_TAX_RATE_Decimal * SubTotalDecimal)
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.