I have this home work question and I don't know what I am doing wrong there are a lot of errors which I don't know how to correct. This the question:
An automative service shop performs the following services (all the services below are assigned a value):
- Oil Change
- Lube Job
- Radiator flush
- Transmision flush inspection
- Muffler replacement and
- Tire rotation
Create an application that displays the total for a customer's visit. This is my code so far:
Public Class Form1
'class level declerations
Const decTax_Rate As Decimal = 0.06D ' TaX on Parts only
Const decOilChange As Decimal = 26 ' cost of oil change
Const decLubeJob As Decimal = 18 ' cost for lube job
Const decRadiator As Decimal = 30 ' cost for Raditor Flush
Const decTransmission As Decimal = 80 ' cost of transmission work
Const decInspection As Decimal = 15 ' cost of inspection
Const decReplaceMuffler As Decimal = 100 'cost of replacing muffler
Const decRotateTire As Decimal = 20 'cost of rotating tire
End Class
Private Sub btnCalculate_Click(....) Handles btnCalculate.Click ( Error: Identify expected. I put in the following identifiers( Byval decpart as decimal and so on) but still underline the whole procedure as statement is not valid in a namespace)
' The procedure calculate the service total
Dim decPart As Decimal ' hold charges for parts
Dim decServiceLabor As Decimal ' hold charges for labor and other services
Dim decTaxCharges As Decimal ' hold sales tax on parts
Dim decTotalCharges As Decimal ' hold total charges
decServiceLabor = OilLubeCharges() + FlushCharges() + MiscCharges() + OtherCharges()
decPart = part1
decTaxCharges = CalcTax(decParts)
decTotalCharges = decOtherCharges + decTaxCharges
lblServiceString.Text = decServiceLabor.ToString("c")
lblParts.Text = decPart.ToString("c")
lblPartsTax.Text = decTax_Rate.ToString("c")
lblTotalFees.Text = decTotalCharges.ToString("c")
End Sub
Private Sub btnClear_Click(...) Handles btnClear.Click
' This procedur clears the controls to default values
ClearOilLube() ' Clear the check boxes for oil and Lube jobs
ClearFlushes() ' Clear the check boxes for radiation and transmission
ClearsMisc() ' Clear the check boxes for inspection muffler and tire
ClearOther() ' Clear the text boxes for parts and labor
ClearFees() ' Clear the summary lables
End Sub
Private Sub btnExit_Click(...) Handles btnExit.Click
' Close the form.
Me.Close()
End Sub
Function OilLubeCharges(ByVal decOilChange As Decimal) As Decimal
' This function returns the charges for an oil change and or lube job.
Dim decOilLube As Decimal = 0D
If chkOilChange.Checked = True Then
decOilLube += decOilChange
End If
If chkLubeJob.Checked = True Then
decOilLube += decLubeJob
End If
Return decOilLube
End Function
Function MiscCharges(ByVal decInspection As Decimal) As Decimal
'The function returns the total charges for an inspection, muffler replacement and/or a tire rotation
Dim decMisc As Decimal = 0D
If chkInspection.Checked = True Then
decMisc += decInspection
End If
If chkReplaceMuffler.Checked = True Then
decMisc += decReplaceMuffler
End If
If chkTireRotation.Checked = True Then
decMisc += decRotateTire
End If
Return decMisc
End Function
Function FlushCharges(ByVal decRadiator As Decimal) As Decimal
'This function return the total charges for a radiator flush and/or a tansmission flush
Dim decFlush As Decimal = 0D
If chkRadiatorFlush.Checked = True Then
decFlush += decRadiator
End If
If chkTrasmission.Checked = True Then
decFlush += decTransmission
End If
Return decFlush
End Function
Function Parts(ByVal decpart As Decimal) As Decimal
' To hold the parts sales
Dim decPart1 As Decimal
decPart1 += decpart
Return decPart1
End Function
Function CalcTax(ByVal decpart As Decimal) As Decimal
' This Function receives the sales part and returns the sale part tax.
Return decpart * decTax_Rate
End Function
Sub ResetOil()
' This procedure resets the oil and lube job.
chkOilChange.Checked = False
chkLubeJob.Checked = False
End Sub
Sub ResetMisc()
' This procedure resets the misc
chkInspection.Checked = False
chkReplaceMuffler.Checked = False
chkTireRotate.Checked = False
End Sub
Sub ResetFlushFluids()
' This procedure resets the flush
chkRadiatorFlush.Checked = False
chkTrasmission.Checked = False
End Sub
Sub ResetPrice()
' This procedure resets the price
lblServiceString.Text = String.Empty
lblParts.Text = String.Empty
lblPartsTax.Text = String.Empty
lblTotalFees.Text = String.Empty
End Sub
Actually all the first line of the functions were underlined as invalid namespace statements and all the procedures need identifiers even after I put in an Identify. There weren't any errors in the class form.
Any suggestions?
For Starters you need to make sure that your
Buttonevents andFunctionsare part of yourForm1Class.