Phuong trinh bac hai

78 0 0
                                        

Option Explicit

Dim a, b, c As Single

Private Sub cmd1_Click()

a = Val(txt1)

b = Val(txt2)

c = Val(txt3)

If (a = 0) Then

txt5 = ""

lbl5 = " "

Dim t As String

t = MsgBox("Ban can nhap du lieu truoc khi tinh", 4 + 16, "Thoâng baùo")

Else

Dim d, x1, x2 As Single

d = (b * b) - (4 * a * c)

If d < 0 Then

    lbl5 = "PT voâ nghieäm"

        txt5.Visible = False

        lbl7(1).Visible = False

         txt4.Visible = False

        lbl6.Visible = False

Else

    If (d = 0) Then

        lbl5 = "PT coù moät nghieäm"

        lbl6.Caption = "X ="

        txt4 = Str(-b / (2 * a))

        txt5.Visible = False

        lbl7(1).Visible = False

         txt4.Visible = True

        lbl6.Visible = True

    Else

        x1 = ((-b) - Sqr(d)) / (2 * a)

        x2 = ((-b) + Sqr(d)) / (2 * a)

        txt4.Visible = True

        lbl6.Visible = True

        txt5.Visible = True

        lbl7(1).Visible = True

txt4 = Str(Mid(Str(x1), 1, InStr(1, Str(x1), ".", 1) + 2))

txt5 = Str(Mid(Str(x2), 1, InStr(1, Str(x2), ".", 1) + 2))

lbl5 = "PT coù hai nghieäm"

    End If

   End If

   End If

End Sub

Private Sub cmd2_Click()

txt1 = ""

txt2 = ""

txt3 = ""

txt1.SetFocus

End Sub

Private Sub cmd3_Click()

lbl5 = ""

txt4 = ""

txt5 = ""

End Sub

Private Sub cmd4_Click()

Dim t As String

t = MsgBox("Ban có muon thoat khong?", 4 + 16, "Thoâng baùo")

If t = vbYes Then

End

End If

End Sub

You've reached the end of published parts.

⏰ Last updated: Jun 23, 2011 ⏰

Add this story to your Library to get notified about new parts!

Phuong trinh bac haiWhere stories live. Discover now