Private Sub Calculer(i As Byte) 'calcul des totaux
Dim j As Byte

If TxtHono = vbNullString Then MsgBox "pas d'honoraire mentionné": Exit Sub

Controls("TxtCA" & i).Value = Controls("TxtCOB" & i).Value * TxtHono.Value

TxtCOBTOTCOMP = 0
TxtCATOTCOMP = 0
TxtCOBTOTCOM = 0
TxtCATOTCOM = 0
TxtCOBTOTAN = 0
TxtCATOTAN = 0

For j = 1 To 12
    With TxtCOBTOTCOMP
        If Controls("TxtCOB" & j) <> vbNullString Then
            If .Value = 0 Then
                .Value = CDbl(Controls("TxtCOB" & j).Value)
            Else:
                .Value = CDbl(.Value) + CDbl(Controls("TxtCOB" & j).Value)
            End If
        End If
    End With

    With TxtCATOTCOMP
        If Controls("TxtCA" & j) <> vbNullString Then
            If .Value = 0 Then
                .Value = CDbl(Controls("TxtCA" & j).Value)
            Else:
            .Value = CDbl(.Value) + CDbl(Controls("TxtCA" & j).Value)
            End If
        End If
    End With
Next j

For j = 5 To 16
    With TxtCOBTOTCOM
        If Controls("TxtCOB" & j) <> vbNullString Then
            If .Value = 0 Then
                .Value = CDbl(Controls("TxtCOB" & j).Value)
            Else:
                .Value = CDbl(.Value) + CDbl(Controls("TxtCOB" & j).Value)
            End If
        End If
    End With
    
    With TxtCATOTCOM
        If Controls("TxtCA" & j) <> vbNullString Then
            If .Value = 0 Then
                .Value = CDbl(Controls("TxtCA" & j).Value)
            Else:
            .Value = CDbl(.Value) + CDbl(Controls("TxtCA" & j).Value)
            End If
        End If
    End With
Next j

For j = 8 To 19
    With TxtCOBTOTAN
        If Controls("TxtCOB" & j) <> vbNullString Then
            If .Value = 0 Then
                .Value = CDbl(Controls("TxtCOB" & j).Value)
            Else:
                .Value = CDbl(.Value) + CDbl(Controls("TxtCOB" & j).Value)
            End If
        End If
    End With

    With TxtCATOTAN
        If Controls("TxtCA" & j) <> vbNullString Then
            If .Value = 0 Then
                .Value = CDbl(Controls("TxtCA" & j).Value)
            Else:
            .Value = CDbl(.Value) + CDbl(Controls("TxtCA" & j).Value)
            End If
        End If
    End With

Next j

End Sub