2012-03-02 18 views
0

我有這個家庭工作的問題,我不知道我在做什麼錯誤有很多錯誤,我不知道如何糾正。這個問題:我如何解決這個程序和Visual Basic中的功能

的AUTOMATIVE服務店提供下列服務(以下所有的服務都分配一個值):

  • 換油
  • 潤滑油招聘
  • 散熱器沖洗
  • Transmision平齊檢查
  • 消聲器更換和
  • 輪胎旋轉

創建一個顯示客戶訪問總數的應用程序。這是到目前爲止我的代碼:

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 

其實函數的所有第一線被強調爲無效的命名空間聲明,所有的程序都需要標識符我把在確定後還是一樣。班級表格中沒有任何錯誤。

有什麼建議嗎?

+5

歡迎來到StackOverflow。輸入單詞「error」之後你應該做的第一件事就是開始輸入你得到的** exact **錯誤,包括任何錯誤信息。你期望人們猜測什麼不起作用以及錯誤可能是什麼。我們非常樂意幫助您爲您的家庭作業問題找到解決方案,但我們不會爲您做到這一點。請修改您的問題,以表明您所得到的確切錯誤,以及它們是否與特定代碼相關(表示註釋)哪些行導致錯誤。它會幫助你更快得到答案。謝謝。 :) – 2012-03-02 20:51:10

+2

我們不會只爲你做功課。詢問關於您的某個錯誤的具體問題,您將更有可能得到答案。從外觀上看,這可能會讓你問幾個問題。 – N0Alias 2012-03-02 20:54:28

回答

0

對於初學者,您需要確保您的Button活動和Functions屬於Form1課程的一部分。

Public Class Form1 

    Private Sub btnCalculate_Click(sender As System.Object, e As System.EventArgs) Handles btnCalculate.Click 

    End Sub 

    Private Sub btnClear_Click(sender As System.Object, e As System.EventArgs) Handles btnClear.Click 

    End Sub 
End Class 
+0

感謝您的建議,它以某種方式工作,但它現在說:「處理子句需要在btnCalculate按鈕上包含在包含類型或其基本類型中定義的一個withEvent變量」。我如何編寫WithEvent類型。 – user1239164 2012-03-03 00:48:30

+0

@ user1239164您是否在編程創建按鈕?然後你的定義應該是這樣的'Dim WithEvents btnCalculate As New Button' – 2012-03-03 01:21:32

+0

@ user1239164我也假設你只有一個Form1形式,並且你的按鈕在這個Form上。 – 2012-03-03 01:28:01

相關問題