huu.tunnel
Thành viên mới
- Tham gia
- 28/9/10
- Bài viết
- 4
- Được thích
- 0
Function PTB2(a As Double, b As Double, c As Double, Optional x As Long) As String
Dim Denta As Double, Checked As Boolean
Denta = b ^ 2 - 4 * a * c
If Denta > 0 Then
Checked = True
X1 = (-b + Denta ^ (1 / 2)) / (2 * a)
X2 = (-b - Denta ^ (1 / 2)) / (2 * a)
ElseIf Denta = 0 Then
Checked = True
X1 = -b / (2 * a)
X2 = -b / (2 * a)
Else
Checked = False
End If
'=========================================
If Checked = True Then
If x = 1 Then
PTB2 = "X1=" & X1
ElseIf x = 2 Then
PTB2 = "X2= " & X2
Else
PTB2 = "X1= " & X1 & " X2= " & X2
End If
Else
PTB2 = "Phuong trinh vo nghiem"
End If
End Function
Dim Denta As Double, Checked As Boolean
Denta = b ^ 2 - 4 * a * c
If Denta > 0 Then
Checked = True
X1 = (-b + Denta ^ (1 / 2)) / (2 * a)
X2 = (-b - Denta ^ (1 / 2)) / (2 * a)
ElseIf Denta = 0 Then
Checked = True
X1 = -b / (2 * a)
X2 = -b / (2 * a)
Else
Checked = False
End If
'=========================================
If Checked = True Then
If x = 1 Then
PTB2 = "X1=" & X1
ElseIf x = 2 Then
PTB2 = "X2= " & X2
Else
PTB2 = "X1= " & X1 & " X2= " & X2
End If
Else
PTB2 = "Phuong trinh vo nghiem"
End If
End Function