Hallo Zusammen,
Ich will 5 Kurven in einem PictureBox zeichnen und für jede Parameter gibt's einen Button, wenn ich den ersten Button klicke, bekomme ich eine Kurve aber wenn ich die zweite Parameter eingebe und den zweiten Button klicke, gibt es zwar eine zweite Kurve aber die erste Kurve ist nicht mehr da. Hier ist der Code für eine Kurve:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button1.Click
cb1 = Val(TextBox1.Text)
If Not IsNumeric(Me.TextBox1.Text) Then
MsgBox("Falsche Eingabe, bitte nur numerische Werte eingeben!")
Me.TextBox1.Select()
End If
Berechnung1()
XY_Graph1()
End Sub
Sub Berechnung1()
For i = 0 To N
X_Array1(i) = i * (0.99 / N)
Y_Array1(i) = (X_Array1(i) / (1 - X_Array1(i))) * ((1 + cb1 ^ 2) / _
2)
Next
End Sub
Sub XY_Graph1()
myg.Clear(Color.LemonChiffon)
X_Achse1()
Y_Achse1()
Zeichnen_Verlauf1()
PictureBox1.Image = bmp
End Sub
Sub X_Achse1()
Dim P00 As New Point(Pixel_X0, Pixel_Y0)
Dim PX0 As New Point(PictureBox1.Width, Pixel_Y0)
Dim dX As Single = (PictureBox1.Width - Pixel_X0) / 10
myg.DrawLine(New Pen(Color.Black, 2), P00, PX0)
For i = 0 To PictureBox1.Width Step dX
myg.DrawLine(New Pen(Color.Black, 1), Pixel_X0 + i + dX, 0, _
Pixel_X0 + i + dX, Pixel_Y0)
myg.DrawLine(New Pen(Color.Black, 1), Pixel_X0 + i + dX, Pixel_Y0, _
Pixel_X0 + i + dX, Pixel_Y0 - 10)
myg.DrawLine(New Pen(Color.Black, 1), Pixel_X0 + i + dX \ 2, _
Pixel_Y0, Pixel_X0 + i + dX \ 2, Pixel_Y0 - 5)
myg.DrawString((i \ dX) * 0.1, New Font("Arial", 10), _
Brushes.Black, i + Pixel_X0 - 6, Pixel_Y0 + 5)
Next
End Sub
Sub Y_Achse1()
Dim P00 As New Point(Pixel_X0, Pixel_Y0)
Dim P0Y As New Point(Pixel_X0, 0)
Dim dY As Single = (PictureBox1.Height - Pixel_X0) / 10
myg.DrawLine(New Pen(Color.Black, 2), P00, P0Y)
For i = PictureBox1.Height - Pixel_X0 To 0 Step -dY
myg.DrawLine(New Pen(Color.Black, 1), Pixel_X0, i, _
PictureBox1.Width, i)
myg.DrawLine(New Pen(Color.Black, 1), Pixel_X0, i, Pixel_X0 + 10, i)
myg.DrawLine(New Pen(Color.Black, 1), Pixel_X0, i - dY \ 2, _
Pixel_X0 + 5, i - dY \ 2)
myg.DrawString("0", New Font("Arial", 10), Brushes.Black, Pixel_X0 _
- 13, Pixel_Y0 - 10)
myg.DrawString("0,1", New Font("Arial", 10), Brushes.Black, _
Pixel_X0 - 26, Pixel_Y0 - (1 * 42) - 10)
myg.DrawString("0,2", New Font("Arial", 10), Brushes.Black, _
Pixel_X0 - 26, Pixel_Y0 - (2 * 42) - 10)
myg.DrawString("0,3", New Font("Arial", 10), Brushes.Black, _
Pixel_X0 - 26, Pixel_Y0 - (3 * 42) - 10)
myg.DrawString("0,4", New Font("Arial", 10), Brushes.Black, _
Pixel_X0 - 26, Pixel_Y0 - (4 * 42) - 10)
myg.DrawString("0,5", New Font("Arial", 10), Brushes.Black, _
Pixel_X0 - 26, Pixel_Y0 - (5 * 42) - 10)
myg.DrawString("0,6", New Font("Arial", 10), Brushes.Black, _
Pixel_X0 - 26, Pixel_Y0 - (6 * 42) - 10)
myg.DrawString("0,7", New Font("Arial", 10), Brushes.Black, _
Pixel_X0 - 26, Pixel_Y0 - (7 * 42) - 10)
myg.DrawString("0,8", New Font("Arial", 10), Brushes.Black, _
Pixel_X0 - 26, Pixel_Y0 - (8 * 42) - 10)
myg.DrawString("0,9", New Font("Arial", 10), Brushes.Black, _
Pixel_X0 - 26, Pixel_Y0 - (9 * 42) - 10)
Next
End Sub
Sub Zeichnen_Verlauf1()
Dim points(N) As PointF
Dim DrawFont As New Font("Arial", 16)
Dim DrawBrush As New SolidBrush(Color.Black)
Dim dX As Single = (PictureBox1.Width - Pixel_X0) / 10
Dim dY As Single = (PictureBox1.Height - Pixel_X0) / 10
For i = 0 To N
points(i).X = X_Array1(i) * dX * 10 + Pixel_X0
points(i).Y = -(Y_Array1(i) * dY * 10) + Pixel_Y0
Next
myg.DrawLines(New Pen(Color.Red, 3), points)
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Me.Load
bmp = New Bitmap(PictureBox1.ClientSize.Width, _
PictureBox1.ClientSize.Height)
myg = Graphics.FromImage(bmp)
g1 = PictureBox1.CreateGraphics
PictureBox1.Image = bmp
End SubVielen Dank für euere Hilfe im Voraus... |