Courbe

sarra68 Messages postés 16 Date d'inscription mercredi 19 janvier 2011 Statut Membre Dernière intervention 16 mars 2011 - 16 mars 2011 à 20:02
cs_rt15 Messages postés 3874 Date d'inscription mardi 8 mars 2005 Statut Modérateur Dernière intervention 7 novembre 2014 - 15 mai 2011 à 18:23
bonjour j'ai fait ce code pour resoudre une équation ax²+bx+c=0
Public Class Form1
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim delta As Integer = b ^ 2 - 4 * a * c
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

If delta = 0 Then
MsgBox("s = " & -b / 2 * a, MsgBoxStyle.Information)
ElseIf delta > 0 Then
MsgBox("s1 " & (-b - Math.Sqrt(delta) / 2 * a & Chr(13) & "s2" & (-b + Math.Sqrt(delta)) / 2 * a))
ElseIf delta < 0 Then
MsgBox("pas de solution")
End If
End Sub




End Class
mais je n'arrive pas à lier ca pour faire une courbe
merci beaucoup

3 réponses

cs_ShayW Messages postés 3253 Date d'inscription jeudi 26 novembre 2009 Statut Membre Dernière intervention 3 décembre 2019 57
17 mars 2011 à 21:00
Salut
mais je n'arrive pas à lier ca pour faire une courbe

quel rapport
ton code résoud une équation au carré
ce sont deux ou un ou zero point sur l'axe
des x
0
Utilisateur anonyme
21 mars 2011 à 00:31
Salut,
Tu peux faire un peu comme ceci
Public Class Form1

    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim x, _decal As Integer
        Dim y1, y2, a, b, c, _zoom As Double

        'decal sert à deplacer les axes sur le formulaire
        _decal = 100
        'zoom sert à agrandir la courbe
        _zoom = 1.7

        'variables à changer
        a = 0.2
        b = -4
        c = -20

        'dessin des axes
        e.Graphics.DrawLine(New Pen(Color.Black), 0, CType(_decal * _zoom, Integer), Me.Width, CType(_decal * _zoom, Integer))
        e.Graphics.DrawLine(New Pen(Color.Black), CType(_decal * _zoom, Integer), 0, CType(_decal * _zoom, Integer), Me.Height)

        'on fait varier x pour calculer y1 et y2
        For x = -_decal To _decal
            y1 = (a * ((x - 1) ^ 2)) + (b * (x - 1)) + c
            y2 = (a * (x ^ 2)) + (b * x) + c
            'on dessine une ligne entre nos 2 points
            e.Graphics.DrawLine(New Pen(Color.Red, 2), _
                       New Point(CType((x - 1 + _decal) * _zoom, Integer), CType((y1 + _decal) * _zoom, Integer)), _
                       New Point(CType((x + _decal) * _zoom, Integer), CType((y2 + _decal) * _zoom, Integer)))
        Next

        'reprise de ton calcul
        Dim delta As Double = (b ^ 2) - (4 * (a * c))

        'dessin des calculs sur le formulaire
        If delta = 0 Then
            e.Graphics.DrawString("s= " & (-b / (2 * a)).ToString, New Font("Arial", 10, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.Blue, 5, 5)
        ElseIf delta > 0 Then
            e.Graphics.DrawString("s1= " & (-b - Math.Sqrt(delta) / 2 * a).ToString, New Font("Arial", 15, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.Blue, 5, 5)
            e.Graphics.DrawString("s2= " & ((-b + Math.Sqrt(delta)) / 2 * a).ToString, New Font("Arial", 15, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.Blue, 5, 20)
        ElseIf delta < 0 Then
            e.Graphics.DrawString("Pas de solution", New Font("Arial", 15, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.Blue, 5, 5)
        End If
    End Sub
End Class

Bonne nuit.
0
cs_rt15 Messages postés 3874 Date d'inscription mardi 8 mars 2005 Statut Modérateur Dernière intervention 7 novembre 2014 13
15 mai 2011 à 18:23
Bonjour,

Pour une question VB.NET, il fallait poster sur vbfrance dans un thème VB.NET.

[ Déplacé sur vbfrance ]
0
Rejoignez-nous