2016-04-10 13 views
0

私は完全にコーディングするのが初めてです。私は、ボタンをクリックしてアクセスするイベントプロシージャを作成しようとしていますが、それぞれ独立して変数があり、なぜプロセスが失敗しているのかわかりません。私は、イベントプロシージャが縛られているAccessの計算ボックスをクリックすると、エラーも表示されません。ここまで私がこれまで持っていたことがあります。そして、このような全てのコードブロック修正VB.netアクセスの電卓

Dim GrandTotalIncome As Currency 
Dim Factor As Currency 

オプションは、最初のデータベース

Private Sub CalculateButton_Click() 

    Dim TotalIncomeAmt As Integer 
    Dim TotalSocialSecurityIncomeAmt As Integer 
    Dim TotalSocialSecurityBenefitAmt As Integer 
    Dim TotalChildSupportAmt As Integer 
    Dim TotalFoodStampAmt As Integer 
    Dim TotalOtherIncomeAmt As Integer 
    Dim GrandTotalIncome As Integer 

    If IFW - How_often_received = "Weekly" Then 
     TotalIncomeAmt = IFW_Amount * 4.25 
    End If 
    If IFW - How_often_received = "Bi-Monthly" Then 
     TotalIncomeAmt = IFW_Amount * 2 
    End If 
    If IFW - How_often_received = "Monthly" Then 
     TotalIncomeAmt = IFW_Amount 
    End If 
    If IFW - How_often_received = " " Then 
     TotalIncomeAmt = 0 
    End If 

    If SSI - How_often_received = "Weekly" Then 
     TotalSocialSecurityIncomeAmt = SSI_Amount * 4.25 
    End If 
    If SSI - How_often_received = "Bi-Monthly" Then 
     TotalSocialSecurityIncomeAmt = SSI_Amount * 2 
    End If 
    If SSI - How_often_received = "Monthly" Then 
     TotalSocialSecurityIncomeAmt = SSI_Amount 
    End If 
    If SSI - How_often_received = " " Then 
     TotalSocialSecurityIncomeAmt = 0 
    End If 

    If SSB - How_often_received = "Weekly" Then 
     TotalSocialSecurityBenefitAmt = SSB_Amount * 4.25 
    End If 
    If SSI - How_often_received = "Bi-Monthly" Then 
     TotalSocialSecurityBenefitAmt = SSB_Amount * 2 
    End If 
    If SSI - How_often_received = "Monthly" Then 
     TotalSocialSecurityBenefitAmt = SSB_Amount 
    End If 
    If SSI - How_often_received = " " Then 
     TotalSocialSecurityBenefitAmt = 0 
    End If 

    If CH - How_often_received = "Weekly" Then 
     TotalChildSupportAmt = CH_Amount * 4.25 
    End If 
    If CH - How_often_received = "Bi-Monthly" Then 
     TotalChildSupportAmt = CH_Amount * 2 
    End If 
    If CH - How_often_received = "Monthly" Then 
     TotalChildSupportAmt = CH_Amount 
    End If 
    If CH - How_often_receive_benefits = " " Then 
     TotalChildSupportAmt = 0 
    End If 

    If FS - How_often_received = "Weekly" Then 
     TotalFoodStampAmt = FS_Dollar_Amount * 4.25 
    End If 
    If FS - How_often_received = "Bi-Monthly" Then 
     TotalFoodStampAmt = FS_Dollar_Amount * 2 
    End If 
    If FS - How_often_received = "Monthly" Then 
     TotalFoodStampAmt = FS_Dollar_Amount 
    End If 
    If FS - How_often_received = " " Then 
     TotalFoodStampAmt = 0 
    End If 

    If OI - How_often_received = "Weekly" Then 
     TotalOtherIncomeAmt = OI_Amount * 4.25 
    End If 
    If OI - How_often_received = "Bi-Monthly" Then 
     TotalOtherIncomeAmt = OI_Amount * 2 
    End If 
    If OI - How_often_received = "Monthly" Then 
     TotalOtherIncomeAmt = OI_Amount 
    End If 
    If OI - How_often_received = "None" Then 
     TotalOtherIncomeAmt = 0 
    End If 

    GrandTotalIncome = (TotalIncomeAmt + TotalBenefitsAmt + TotalFoodStampAmt + TotalChildSupportAmt + TotalOtherIncomeAmt) 
    Total_Monthly_Income = GrandTotalIncome 
End Sub 
+0

は毎週の計算が 'で行われるべきではありません0.25' ? –

+3

これは、 'IFW - How_often_received =" Weekly "'を意味しますか?私が読んだのは、How_often_receivedからのSubstract IFWで、その結果を 'Weekly'という文字列と比較することです。これは私には意味がありません。あなたはこれをどこにでも持っています。 –

+0

@ThomasGが指摘したことは、再訪する必要があるとして最初に現れたことでした。もう一度考え直すことは、複数の条件が成り立つ可能性があることです。その場合、変更したい: 'TotalIncomeAmt = IFW_Amount * 4.25'から' TotalIncomeAmt = TotalIncomeAmt +(IFW_Amount * 4.25) ' –

答えて

0

を比較

Dim TotalIncomeAmt As Currency ' To hold decimals 
' Also, IFW_Amount must be Currency. 


Select Case [IFW - How_often_received] 
    Case "Weekly" 
     Factor = 4.25 
    Case "Bi-Monthly" 
     Factor = 2 
    Case "Monthly" 
     Factor = 1 
    Case Else 
     Factor = 0 
End Select 
TotalIncomeAmt = IFW_Amount * Factor