Sub calc()
Dim p As Byte, i As Byte
For i = 1 To 6
With Me.Controls("TextBox" & (i))
.Text = Replace(.Text, ".", ",")
.ForeColor = 0
If .Text <> "" Then
p = p + 2 ^ (i - 1)
Else
.Text = 0
End If
End With
Next
On Error GoTo E
Application.EnableEvents = False
Select Case p
Case 33: Me.TextBox2.Value = CDbl(Me.TextBox1.Value) / (2) ^ CDbl(Me.TextBox6.Value)
Case 25, 29: Me.TextBox2.Value = CDbl(Me.TextBox1.Value) / Exp(CDbl(Me.TextBox4.Value) * CDbl(Me.TextBox5.Value))
Case 26, 30: Me.TextBox1.Value = CDbl(Me.TextBox2.Value) * Exp(CDbl(Me.TextBox4.Value) * CDbl(Me.TextBox5.Value))
Case 19, 23: Me.TextBox4.Value = Log(CDbl(Me.TextBox1.Value) / CDbl(Me.TextBox2.Value)) / CDbl(Me.TextBox5.Value)
Case 11, 15: Me.TextBox5.Value = Log(CDbl(Me.TextBox1.Value) / CDbl(Me.TextBox2.Value)) / CDbl(Me.TextBox4.Value)
Case Else: For i = 1 To 5: Me.Controls("TextBox" & (i)).ForeColor = 255: Next
End Select
Application.EnableEvents = True
Exit Sub
E:
MsgBox "Une erreur imprévue est survenue..."
End Sub