mercredi 6 janvier 2016

Multiple If Statements Indentation Error?

So, I think I am doing something wrong but need a little guidance.

Below Code is supposed a calculation one way based on a combobox "Awarding" result. Currently my calculation is doing the calculation incorrectly (as it is thinking it is "both halfs same term"). I believe this is due to my indentation or incorrect use of multiple nested if statements.

 If Awarding = "First Half All Credits in One Half" Or Awarding = "Second Half Only" Then
     If LEU.Value <> "" And PLEU < CalcElig Then
         Payment1.Value = PLEU
     If PAmtUnused < CalcElig Then
         Payment1.Value = PAmtUnused
     Else: Payment1.Value = Payment1.Value = Round(CLng(PSchAward) *      PTotalAyWeeks / PMinAyWeeks / 2, 0)
     End If

     PPayment1 = Payment1.Value
     PPayment2 = 0
     TotalPayment = PPayment1 + PPayment2
     End If
 End If


 If Awarding = "Both Halfs Same Term" Then
     If LEU.Value <> "" And PLEU < CalcEligA Then
         Payment1.Value = PLEU
     ElseIf PAmtUnused < CalcEligA Then
         Payment1.Value = PAmtUnused
     Else: Payment1.Value = CalcEligA
     End If


     PPayment1 = Payment1.Value


     If LEU.Value <> "" And PLEU > 0 Then
         Payment2.Value = PLEU - PPayment1
     Else: Payment2.Value = CalcEligB
     End If

     If PAmtUnused - PPayment1 < PLEU - PPayment1 Then
         Payment2.Value = PAmtUnused - PPayment1
     ElseIf PAmtUnused - PPayment1 < CalcEligB Then
         Payment2.Value = PAmtUnused - PPayment1
     Else: Payment2.Value = CalcEligB
     End If


     PPayment2 = Payment2.Value

     TotalPayment = PPayment1 + PPayment2

     End If

 End If

 End Sub

Aucun commentaire:

Enregistrer un commentaire