pouvez vous me dire les fautes que jai faites pour ce programme en vb d'équation de troisième degrés:
Option Explicit
Dim XX As Integer
Dim Fot As String
Private Sub cmdCalcul_Click()
Dim A, b, c, d, X3, X2, X1 As Double
Dim a0, a1, a2, a3, y, p, q, w, E, b1, u, s, u1, c1, u2, i As Double
Dim REP As String
A = Val(txtcoA.txt)
b = Val(txtcoB.txt)
c = Val(txtcoC.txt)
d = Val(txtcoD.txt)
If A = 0 Then
REP = vbCrLf & " Equation du second degrés"
Select Case b
Case 0
REP = vbCrLf & " Equation impossible"
lblREP.Caption = REP
Exit Sub
End Select
End If
a0 = A / A
a1 = b / A
a2 = c / A
a3 = d / A
y = X1 + (a3 / 3)
p = a2 - ((a1 * a1) / 3)
q = a3 - ((a1 * a2) / 3) + ((2 * a1 * a1) / 27)
b1 = a1 / 3
R = (q / 2) ^ 2 + (p / 3) ^ 3
If R < 0 Then
REP = REP & vbCrLf & " trois racines réelles"
lbl.Caption = REP
Exit Sub
End If
E = Tan(w) = (-2 * Sqr(-R)) / q
s = 2 * Sqr(-(p / 3))
u = w / 3
X1 = scos(u) - b1
X1 = Format(X1, "######,#####" )
X2 = scos(u + 120) - b1
X2 = Format(X2, "######,#####" )
X3 = scos(u + 240)
X3 = Format(X3, "######,#####" )
If R > 0 Then
REP = vbCrLf & "1 racine réelle et 2 complexes"
lblCaption = REP
Exit Sub
End If
u1 = spr((-q / 2) + Sqr(R)) ^ 3
i*i = -1
X1 = u1 - c1 - b1
X1 = Format(X1, "######,#####" )
X2 = (0.5 * (c1 - u1)) - (b1 + (0.5 * Sqr(3) * (u1 + c1)))i
X2 = Format(X2, "######,#####" )
X3 = im(X2)
X3 = Format(X3, "######,#####" )
If R = 0 Then
REP = vbCrLf & " 1 simple et une double ou bien une triple si q=p=0"
lbl.Caption = REP
Exit Sub
End If
V1 = -2 * u1
u2 = -Sqr(-(q / 2)) ^ 2
X1 = u1 - b1
X1 = Format(X1, "######,#####" )
X2 = X3 = u2 - b1
X2 = Format(X2, "######,#####" )
End If
With lblREP
.Caption = REP
.FontSize = 16
End With
End Sub
Private Sub cmdFin_Click()
End
End Sub
Private Sub cmdrefaire_Click()
txtcoA.Text = ""
txtcoB.Text = ""
txtcoC.Text = ""
txtcoD.Text = ""
lbl.Caption = ""
lbl.FOTCaption = ""
Fot = ""
XX = 0
txtcoA.SetFocus
End Sub
Private Sub txtcoA_keyPress(KeyAscii As Integer)
Dim A As Integer
A = KeyAscii
Select Case A
Case 48 To 57
Case 43, 45
If Len(txtcoA.Text) > 0 Then
GoSub Sottise
lblREP.Caption = lblREP.Caption & vbCrLf & _
" signe +/- incohérent ! "
End If
Case 46
If InStr(1, txtcoA.Text, "." ) <> 0 Then
GoSub Sottise
lblREP.Caption = lblREP.Caption & vbCrLf & _
" Point décimal incohérent! "
End If
Case Else
GoSub Sottise
lblREP.Caption = lblREP.Caption & vbCrLf & _
" 1 réel cohérent Merci ! "
End Select
Exit Sub
Sottise:
KeyAscii = 0
Fot = Fot & " X X"
lblFOT.Caption = Fot
XX = XX + 1
If XX > 5 Then
XX = 0
Fot = "X X"
lblREP.Caption = ""
End If
Return
End Sub
Private Sub txtcoB_keyPress(KeyAscii As Integer)
Dim A As Integer
A = KeyAscii
Select Case A
Case 48 To 57
Case 43, 45
If Len(txtcoB.Text) > 0 Then
GoSub Sottise
lblREP.Caption = lblREP.Caption & vbCrLf & _
" signe +/- incohérent ! "
End If
Case 46
If InStr(1, txtcoA.Text, "." ) <> 0 Then
GoSub Sottise
lblREP.Caption = lblREP.Caption & vbCrLf & _
" Point décimal incohérent! "
End If
Case Else
GoSub Sottise
lblREP.Caption = lblREP.Caption & vbCrLf & _
" 1 réel cohérent Merci ! "
End Select
Exit Sub
Sottise:
KeyAscii = 0
Fot = Fot & " X X"
lblFOT.Caption = Fot
XX = XX + 1
If XX > 5 Then
XX = 0
Fot = "X X"
lblREP.Caption = ""
End If
Return
End Sub
Private Sub txtcoC_keyPress(KeyAscii As Integer)
Dim A As Integer
A = KeyAscii
Select Case A
Case 48 To 57
Case 43, 45
If Len(txtcoC.Text) > 0 Then
GoSub Sottise
lblREP.Caption = lblREP.Caption & vbCrLf & _
" signe +/- incohérent ! "
End If
Case 46
If InStr(1, txtcoA.Text, "." ) <> 0 Then
GoSub Sottise
lblREP.Caption = lblREP.Caption & vbCrLf & _
" Point décimal incohérent! "
End If
Case Else
GoSub Sottise
lblREP.Caption = lblREP.Caption & vbCrLf & _
" 1 réel cohérent Merci ! "
End Select
Exit Sub
Sottise:
KeyAscii = 0
Fot = Fot & " X X"
lblFOT.Caption = Fot
XX = XX + 1
If XX > 5 Then
XX = 0
Fot = "X X"
lblREP.Caption = ""
End If
Return
End Sub
Private Sub txtcoD_keyPress(KeyAscii As Integer)
Dim A As Integer
A = KeyAscii
Select Case A
Case 48 To 57
Case 43, 45
If Len(txtcoD.Text) > 0 Then
GoSub Sottise
lblREP.Caption = lblREP.Caption & vbCrLf & _
" signe +/- incohérent ! "
End If
Case 46
If InStr(1, txtcoA.Text, "." ) <> 0 Then
GoSub Sottise
lblREP.Caption = lblREP.Caption & vbCrLf & _
" Point décimal incohérent! "
End If
Case Else
GoSub Sottise
lblREP.Caption = lblREP.Caption & vbCrLf & _
" 1 réel cohérent Merci ! "
End Select
Exit Sub
Sottise:
KeyAscii = 0
Fot = Fot & " X X"
lblFOT.Caption = Fot
XX = XX + 1
If XX > 5 Then
XX = 0
Fot = "X X"
lblREP.Caption = ""
End If
Return
End Sub