giai pt trung phuong code
code
Private Sub cmd_Click()
Dim a, b, c, x, x1, x2, x3, d, t As Double
a = Val(txt1.Text)
b = Val(txt2.Text)
c = Val(txt3.Text)
If a = 0 Then
If b = 0 Then
If c = 0 Then txt4.Text = "phuong trinh co vo so nghiem"
If c <> 0 Then txt4.Text = "phuong trinh vo nghiem"
End If
If b <> 0 Then
If c = 0 Then txt4.Text = "phuong trinh co nghiem x=0"
If c <> 0 Then
x = -c / b
If -c / b > 0 Then txt4.Text = "phuong trinh co nghiem la: x1=" & Sqr(-c / b) & " x2= " & -Sqr(-c / b)
If -c / b < 0 Then txt4.Text = "phuong trinh vo nghiem"
End If
End If
If a <> o Then
d = b * b - 4 * a * c
If d < 0 Then txt4.Text = "phuong trinh vo nghiem"
If d = 0 Then
x1 = -b / 2 * a
If x1 > 0 Then txt4.Text = " phuong trinh co 2 nghiem phan biet: x1=" & Sqr(x1) & " x2=" & -Sqr(x1)
If x1 < 0 Then txt4.Text = "phuong trinh vo nghiem"
End If
If d > 0 Then
x2 = (-b + Sqr(d)) / 2 * a
x3 = (-b + Sqr(d)) / 2 * a
If (x2 > 0) And (x3 > 0) Then txt4 = "phuong trinh co 4 nghiem phan biet la: x1=" & Sqr(x2) & " x2=" & -Sqr(x2) & " x3=" & Sqr(x3) & " x4=" & -Sqr(x3)
If (x2 > 0) And (x3 < 0) Then txt4 = "phuong trinh co 2 nghiem phan biet la: x1=" & Sqr(x2) & " x2=" & -Sqr(x2)
If (x2 > 0) And (x3 > 0) Then txt4 = "phuong trinh co 4 nghiem phan biet la: x1=" & Sqr(x3) & " x2=" & -Sqr(x3)
If (x2 < 0) And (x3 < 0) Then txt4 = "phuong trinh vo nghiem"
End If
End If
End Sub
Bạn đang đọc truyện trên: Truyen247.Pro