//Solution to Quadratic Equations
Dim a, b, c, d, r1, r2
Private Sub cmdexit_Click()
End
End Sub
Private Sub cmdrootchar_Click()
a = txtxsq.Text
b = txtx.Text
c = txtconst.Text
r1 = txtfirstroot.Text
r2 = txtsecondroot.Text
d = b ^ 2 - 4 * a * c
If d > 0 Then
lblrootchar.Caption = "Real Roots"
r1 = ((-b) + Sqr(d)) / 2 * a
r2 = ((-b) - Sqr(d)) / 2 * a
txtfirstroot.Text = r1
txtsecondroot.Text = r2
ElseIf d = 0 Then
lblrootchar.Caption = "Real & Equal Roots"
r1 = r2 = (-b) / 2 * a
txtfirstroot.Text = r1
txtsecondroot.Text = r2
Else
lblrootchar.Caption = "Non Real Roots"
End If
End Sub
No comments:
Post a Comment
Note: only a member of this blog may post a comment.