2012-03-02 6 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。 「エラー」という単語を入力した後にまず行うべきことは、エラーメッセージを含めて**正確な**エラーを入力することです。あなたは、人々が何がうまくいかないのか、そして何がエラーなのかを推測することを期待しています。あなたの宿題の解決策を見つけるお手伝いをしてくれることは喜ばしいことですが、私たちはあなたのためにそれをするつもりはありません。質問を編集して正確なエラーが何であるかを示し、特定のコードに関連している場合は、エラーの原因となっている行(コメント付き)を示してください。より迅速に回答を得るのに役立ちます。ありがとう。 :) –

+2

私たちはあなたの宿題をするつもりはありません。あなたのバグについて特定の質問をすると、答えが得られる可能性が高くなります。それを見れば、これはあなたにいくつかの質問をするかもしれません。 – N0Alias

答えて

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ボタンの "handles節requres a withEvent変数を含む型またはその基本型の1つ"で定義されています。どのようにWithEvent型を記述しますか? – user1239164

+0

@ user1239164ボタンをプログラム的に作成していますか?あなたの定義は次のようなものでなければなりません。 'Dim WithEvents btnCalculate As New Button ' –

+0

@ user1239164私はあなたが' Form1'のフォームしか持っておらず、あなたのボタンがその 'Form'にあると仮定しています。 –

関連する問題