Gut...hat sich hiermit erledigt...hab auch noch einige features eingebaut....
Hier der Code:
Option Explicit
Dim A As Double, B As Double, C As Double, x As Double, Ergebnis As Double
Dim xStart As Double, xStop As Double, xStep As Double, Timer As Double
Private Sub cmdClear_Click()
lstZahlen.Clear
End Sub
Private Sub cmdOK_Click()
If txtxStart.Text >= txtxStop.Text Then
MsgBox "Der StartWert ist größer als der EndWert!", vbOKOnly, "Fehler..."
End If
On Error GoTo ErrHandler
A = CDbl(txtA.Text)
B = CDbl(txtB.Text)
C = CDbl(txtC.Text)
xStep = CDbl(txtxStep.Text)
xStart = CDbl(txtxStart.Text)
xStop = CDbl(txtxStop.Text)
lstZahlen.Clear
For x = xStart To xStop Step xStep
Ergebnis = A * x ^ 2 + B * x + C
lstZahlen.AddItem ("f(" & x & ") " & Ergebnis)
Next
Exit Sub
ErrHandler:
lstZahlen.AddItem ("Keine Lösung")
End Sub
Private Sub cmdZusatz_Click()
If cmdZusatz.Caption = "«" Then
cmdZusatz.Caption = "»"
tmrHover.Enabled = True
Else:
cmdZusatz.Caption = "«"
tmrHover.Enabled = True
End If
End Sub
Private Sub Form_Load()
txtA.Text = "1"
txtB.Text = "2"
txtC.Text = "3"
txtxStart.Text = "0"
txtxStop.Text = "15"
End Sub
Private Sub txtA_Change()
If Not IsNumeric(txtA.Text) Then
MsgBox "Bitte nur Zahlen eingeben!", vbOKOnly, "Fehler..."
txtA.Text = 1
End If
If txtA.Text = 0 Then
MsgBox "Der Wert A kann nicht 0 sein!", vbOKOnly, "Fehler..."
txtA.Text = 1
End If
End Sub
Private Sub txtB_Change()
If Not IsNumeric(txtB.Text) Then
MsgBox "Bitte nur Zahlen eingeben!", vbOKOnly, "Fehler..."
txtB.Text = 2
End If
End Sub
Private Sub txtC_Change()
If Not IsNumeric(txtC.Text) Then
MsgBox "Bitte nur Zahlen eingeben!", vbOKOnly, "Fehler..."
txtC.Text = 3
End If
End Sub
Private Sub txtxStart_Change()
If Not IsNumeric(txtxStart.Text) Then
MsgBox "Bitte nur Zahlen eingeben!", vbOKOnly, "Fehler..."
txtxStart.Text = 0
End If
End Sub
Private Sub txtxStop_Change()
If Not IsNumeric(txtxStop.Text) Then
MsgBox "Bitte nur Zahlen eingeben!", vbOKOnly, "Fehler..."
txtxStop.Text = 15
End If
End Sub
Private Sub txtxStep_Change()
If Not IsNumeric(txtxStep.Text) Then
MsgBox "Bitte nur Zahlen eingeben!", vbOKOnly, "Fehler..."
txtxStep.Text = 1
End If
If txtxStep.Text = 0 Then
MsgBox "Der Wert für den Schritt kann nicht 0 sein!", vbOKOnly, "Fehler..."
txtxStep.Text = 1
End If
End Sub |