Sei sulla pagina 1di 1

Option Explicit Public a As Double, b As Double, c As Double, d As Double Public Sub Delta() a = Sheet1.Cells(1, "A").Value b = Sheet1.Cells(1, "B").Value c = Sheet1.

Cells(1, "C").Value d=b*b-4*a*c Sheet1.Cells(2, "A").Value = d End Sub Public Sub timnghiem() Dim x1 As Variant, x2 As Variant, i As String d = Sheet1.Cells(2, "A").Value a = Sheet1.Cells(1, "A").Value b = Sheet1.Cells(1, "B").Value c = Sheet1.Cells(1, "C").Value If d >= 0 Then x1 = (-b + Sqr(d)) / 2 x2 = (-b - Sqr(d)) / 2 Sheet1.Cells(3, "B").Value = x1: Debug.Print x1 Sheet1.Cells(3, "C").Value = x2: Debug.Print x2 Else x1 = "Vo_nghiem" Sheet1.Cells(3, "B").Value = x1 Debug.Print x1 End If End Sub

Potrebbero piacerti anche