Veillez me couriger ce code ,d'un equation de 2m degre
badbadtoo
Messages postés8Date d'inscriptionjeudi 3 mars 2011StatutMembreDernière intervention28 mars 2011
-
3 mars 2011 à 16:59
badbadtoo
Messages postés8Date d'inscriptionjeudi 3 mars 2011StatutMembreDernière intervention28 mars 2011
-
4 mars 2011 à 09:58
Public Class Form1
Dim a As Double
Dim b As Double
Dim c As Double
Dim d As Double
Dim x1 As Double
Dim x2 As Double
Dim sqrt As Double
Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
End Sub
Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
a = TextBox1.Text
b = TextBox2.Text
c = TextBox3.Text
d = (b * b) - (4 * a * c)
If a 0 And b 0 Then
MsgBox("l’équation n’admet pas de solution ")
Else
If d < 0 Then
MsgBox("la solution est l'ensembl vide ")
Else
If d = 0 And a <> 0 Then
x1 = (-b) / a
TextBox4.Text = x1
Else
If d > 0 And a <> 0 Then
x1 = (-b + (Math.Sqrt(d))) / (2 * a)
x2 = (-b - (Math.Sqrt(d))) / (2 * a)
TextBox4.Text = x1
TextBox5.Text = x2
End If
End If
End If
End If
End Sub
cs_ShayW
Messages postés3253Date d'inscriptionjeudi 26 novembre 2009StatutMembreDernière intervention 3 décembre 201957 3 mars 2011 à 21:39
Bonsoir
c'est un code de mes exercices scolaires
je suis sun technicien en geni informatique
et alors !
Estimes heureux qu'on répond à ton post
à quoi sert l'évenement TextBox4_TextChanged ?
Fais plus simple
If a = 0 Then
MessageBox.Show("ce n'est pas une équation du 2eme degré")
Exit Sub
End If
If d < 0 Then
MessageBox.Show("pas de solution réelle")
Exit Sub
End If
If d = 0 Then
x1 = -b / (2 * a)
Else
x1 = (-b + Math.Sqrt(d)) / (2 * a)
x2 = (-b - Math.Sqrt(d)) / (2 * a)
End If