bài tập giải phương trình bậc 3 bằng VB6 [Lê Minh Huy]
Trang 1 trong tổng số 1 trang
bài tập giải phương trình bậc 3 bằng VB6 [Lê Minh Huy]
Private Sub Command1_Click()
Dim a As Long
Dim b As Long
Dim c As Long
Dim d As Long
Dim delta As Long
Dim delta2 As Long
Dim k As Long
Dim kl As String
a = Val(Text3.Text)
b = Val(Text4.Text)
c = Val(Text5.Text)
d = Val(Text6.Text)
k = Val(Text11.Text)
delta2 = Val(Text12.Text)
If a = 0 And b = 0 And c = 0 And d = 0 Then
kl = "Phuong trinh co vo so nghiem"
X1 = ""
X2 = ""
X3 = ""
Text7.Text = kl
Text8.Text = X1
Text9.Text = X2
Text10.Text = X3
ElseIf a = 0 And b = 0 And c = 0 And d <> 0 Then
kl = "phuong trinh vo nghiem"
X1 = ""
X2 = ""
X3 = ""
Text7.Text = kl
Text8.Text = X1
Text9.Text = X2
Text10.Text = X3
ElseIf a = 0 And b = 0 And c <> 0 Then
kl = "phuong trinh co 1 nghiem duy nhat"
X1 = Val(-d / c)
X2 = ""
X3 = ""
Text7.Text = kl
Text8.Text = X1
Text9.Text = X2
Text10.Text = X3
End If
If a = 0 And b <> 0 And c <> 0 Then
delta = c * c - 4 * b * d
End If
If a = 0 And b <> 0 And c <> 0 And delta < 0 Then
kl = "Phuong trinh vo nghiem"
X1 = ""
X2 = ""
X3 = ""
Text7.Text = kl
Text8.Text = X1
Text9.Text = X2
Text10.Text = X3
ElseIf a = 0 And b <> 0 And c <> 0 And delta = 0 Then
kl = "Phuong trinh co 1 nghiem kep"
X1 = Val(-c / (2 * b))
X2 = ""
X3 = ""
Text7.Text = kl
Text8.Text = X1
Text9.Text = X2
Text10.Text = X3
ElseIf a = 0 And b <> 0 And c <> 0 And delta > 0 Then
kl = "Phuong trinh co 2 nghiem phan biet"
X1 = Val((-c + Sqr(delta)) / (2 * b))
X2 = Val((-c - Sqr(delta)) / (2 * b))
X3 = ""
Text7.Text = kl
Text8.Text = X1
Text9.Text = X2
Text10.Text = X3
End If
If a <> 0 Then
delta2 = Val(b * b - 3 * a * c)
Text12.Text = delta2
End If
If delta2 <> 0 And a <> 0 Then
k = Val((9 * a * b * c) - (2 * b * b * b) - (27 * a * a * d)) / Sqr(Abs(delta2 * delta2 * delta2))
Text11.Text = k
End If
If a <> 0 And delta2 > 0 Then
kl = "Phuong trinh co 3 nghiem"
X1 = Val(((2 * Sqr(delta2) * Cos(((Atn(-k / Sqr(Abs(k * k) + 1))) + (2 * Atn(1))) / 3)) - b) / (3 * a))
X2 = Val(((2 * Sqr(delta2) * Cos((((Atn(-k / Sqr(Abs(k * k) + 1))) + (2 * Atn(1))) / 3)) - ((2 * 3.1457) / 3)) - b) / (3 * a))
X3 = Val(((2 * Sqr(delta2) * Cos((((Atn(-k / Sqr(Abs(k * k) + 1))) + (2 * Atn(1))) / 3)) + ((2 * 3.1457) / 3)) - b) / (3 * a))
Text7.Text = kl
Text8.Text = X1
Text9.Text = X2
Text10.Text = X3
ElseIf a <> 0 And delta2 > 0 And Abs(k) > 1 Then
kl = "Phuong trinh co 1 nghiem duy nhat"
X1 = Val((((Sqr(delta2) * Abs(k)) / (3 * a * k)) * ((Abs(k) + Sqr(k * k - 1)) ^ (1 / 3) + (Abs(k) - Sqr(k * k - 1)) ^ (1 / 3))) - (b / (3 * a)))
X2 = ""
X3 = ""
Text7.Text = kl
Text8.Text = X1
Text9.Text = X2
Text10.Text = X3
End If
If a <> 0 And delta2 = 0 Then
kl = "Phuong trinh co 1 nghiem boi" '(((can bac ba))))'
X1 = Val((-b + (b * b * b - 27 * a * a * d) ^ 1 / 3) / (3 * a))
X2 = ""
X3 = ""
Text7.Text = kl
Text8.Text = X1
Text9.Text = X2
Text10.Text = X3
End If
If a <> 0 And delta2 < 0 Then
kl = "Phuong trinh co 1 nghiem duy nhat" '(((can bac ba)))'
X1 = Val((Sqr(Abs(delta2)) / (3 * a)) * ((Abs(k + Sqr(k * k + 1)) ^ (1 / 3)) + (Abs(k - Sqr(k * k + 1)) ^ (1 / 3))))
X2 = ""
X3 = ""
Text7.Text = kl
Text8.Text = X1
Text9.Text = X2
Text10.Text = X3
End If
End Sub
Private Sub Command2_Click()
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
End Sub
Private Sub Command3_Click()
MsgBox "Are you sure""yes/no"
End
EPrivate Sub Command5_Click()
If (giaiphuongtrinhbac3.nghiem1.Text <> "") Then
xemnghiem.nghiem1.Text = giaiphuongtrinhbac3.nghiem1.Text
xemnghiem.nghiem2.Text = giaiphuongtrinhbac3.nghiem2.Text
xemnghiem.nghiem3.Text = giaiphuongtrinhbac3.nghiem3.Text
Else
xemnghiem.nghiem1.Text = "Chua co de bai, ban phai nhap vao da !"
xemnghiem.nghiem2.Text = "Hay nhap cac he so roi bam nut Tim x !"
xemnghiem.nghiem3.Text = "Bay gio ban hay bam Close de quay lai !"
End If
xemnghiem.Show 1
End Subnd Sub
Dim a As Long
Dim b As Long
Dim c As Long
Dim d As Long
Dim delta As Long
Dim delta2 As Long
Dim k As Long
Dim kl As String
a = Val(Text3.Text)
b = Val(Text4.Text)
c = Val(Text5.Text)
d = Val(Text6.Text)
k = Val(Text11.Text)
delta2 = Val(Text12.Text)
If a = 0 And b = 0 And c = 0 And d = 0 Then
kl = "Phuong trinh co vo so nghiem"
X1 = ""
X2 = ""
X3 = ""
Text7.Text = kl
Text8.Text = X1
Text9.Text = X2
Text10.Text = X3
ElseIf a = 0 And b = 0 And c = 0 And d <> 0 Then
kl = "phuong trinh vo nghiem"
X1 = ""
X2 = ""
X3 = ""
Text7.Text = kl
Text8.Text = X1
Text9.Text = X2
Text10.Text = X3
ElseIf a = 0 And b = 0 And c <> 0 Then
kl = "phuong trinh co 1 nghiem duy nhat"
X1 = Val(-d / c)
X2 = ""
X3 = ""
Text7.Text = kl
Text8.Text = X1
Text9.Text = X2
Text10.Text = X3
End If
If a = 0 And b <> 0 And c <> 0 Then
delta = c * c - 4 * b * d
End If
If a = 0 And b <> 0 And c <> 0 And delta < 0 Then
kl = "Phuong trinh vo nghiem"
X1 = ""
X2 = ""
X3 = ""
Text7.Text = kl
Text8.Text = X1
Text9.Text = X2
Text10.Text = X3
ElseIf a = 0 And b <> 0 And c <> 0 And delta = 0 Then
kl = "Phuong trinh co 1 nghiem kep"
X1 = Val(-c / (2 * b))
X2 = ""
X3 = ""
Text7.Text = kl
Text8.Text = X1
Text9.Text = X2
Text10.Text = X3
ElseIf a = 0 And b <> 0 And c <> 0 And delta > 0 Then
kl = "Phuong trinh co 2 nghiem phan biet"
X1 = Val((-c + Sqr(delta)) / (2 * b))
X2 = Val((-c - Sqr(delta)) / (2 * b))
X3 = ""
Text7.Text = kl
Text8.Text = X1
Text9.Text = X2
Text10.Text = X3
End If
If a <> 0 Then
delta2 = Val(b * b - 3 * a * c)
Text12.Text = delta2
End If
If delta2 <> 0 And a <> 0 Then
k = Val((9 * a * b * c) - (2 * b * b * b) - (27 * a * a * d)) / Sqr(Abs(delta2 * delta2 * delta2))
Text11.Text = k
End If
If a <> 0 And delta2 > 0 Then
kl = "Phuong trinh co 3 nghiem"
X1 = Val(((2 * Sqr(delta2) * Cos(((Atn(-k / Sqr(Abs(k * k) + 1))) + (2 * Atn(1))) / 3)) - b) / (3 * a))
X2 = Val(((2 * Sqr(delta2) * Cos((((Atn(-k / Sqr(Abs(k * k) + 1))) + (2 * Atn(1))) / 3)) - ((2 * 3.1457) / 3)) - b) / (3 * a))
X3 = Val(((2 * Sqr(delta2) * Cos((((Atn(-k / Sqr(Abs(k * k) + 1))) + (2 * Atn(1))) / 3)) + ((2 * 3.1457) / 3)) - b) / (3 * a))
Text7.Text = kl
Text8.Text = X1
Text9.Text = X2
Text10.Text = X3
ElseIf a <> 0 And delta2 > 0 And Abs(k) > 1 Then
kl = "Phuong trinh co 1 nghiem duy nhat"
X1 = Val((((Sqr(delta2) * Abs(k)) / (3 * a * k)) * ((Abs(k) + Sqr(k * k - 1)) ^ (1 / 3) + (Abs(k) - Sqr(k * k - 1)) ^ (1 / 3))) - (b / (3 * a)))
X2 = ""
X3 = ""
Text7.Text = kl
Text8.Text = X1
Text9.Text = X2
Text10.Text = X3
End If
If a <> 0 And delta2 = 0 Then
kl = "Phuong trinh co 1 nghiem boi" '(((can bac ba))))'
X1 = Val((-b + (b * b * b - 27 * a * a * d) ^ 1 / 3) / (3 * a))
X2 = ""
X3 = ""
Text7.Text = kl
Text8.Text = X1
Text9.Text = X2
Text10.Text = X3
End If
If a <> 0 And delta2 < 0 Then
kl = "Phuong trinh co 1 nghiem duy nhat" '(((can bac ba)))'
X1 = Val((Sqr(Abs(delta2)) / (3 * a)) * ((Abs(k + Sqr(k * k + 1)) ^ (1 / 3)) + (Abs(k - Sqr(k * k + 1)) ^ (1 / 3))))
X2 = ""
X3 = ""
Text7.Text = kl
Text8.Text = X1
Text9.Text = X2
Text10.Text = X3
End If
End Sub
Private Sub Command2_Click()
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
End Sub
Private Sub Command3_Click()
MsgBox "Are you sure""yes/no"
End
EPrivate Sub Command5_Click()
If (giaiphuongtrinhbac3.nghiem1.Text <> "") Then
xemnghiem.nghiem1.Text = giaiphuongtrinhbac3.nghiem1.Text
xemnghiem.nghiem2.Text = giaiphuongtrinhbac3.nghiem2.Text
xemnghiem.nghiem3.Text = giaiphuongtrinhbac3.nghiem3.Text
Else
xemnghiem.nghiem1.Text = "Chua co de bai, ban phai nhap vao da !"
xemnghiem.nghiem2.Text = "Hay nhap cac he so roi bam nut Tim x !"
xemnghiem.nghiem3.Text = "Bay gio ban hay bam Close de quay lai !"
End If
xemnghiem.Show 1
End Subnd Sub
leminhhuy- Tổng số bài gửi : 1
Join date : 08/11/2012
Similar topics
» bai giai phuong trinh bang visual basic
» bai tap giai phuong trinh bac 2 dung vb6
» Giải phương trình bậc 3 dùng VB6
» Tài liệu lý thuyết và thực hành môn Vi Điều Khiển 8951
» nguyen ly hoat dong cua IC qua cac cong and,or,nand,nor,xor,exnor ko?
» bai tap giai phuong trinh bac 2 dung vb6
» Giải phương trình bậc 3 dùng VB6
» Tài liệu lý thuyết và thực hành môn Vi Điều Khiển 8951
» nguyen ly hoat dong cua IC qua cac cong and,or,nand,nor,xor,exnor ko?
Trang 1 trong tổng số 1 trang
Permissions in this forum:
Bạn không có quyền trả lời bài viết
|
|
Wed Sep 24, 2014 8:46 am by vinagreensun
» Chia sẻ source code mạch đếm 0-99 sử dụng 8051 và LED hồng ngoại
Mon Mar 24, 2014 2:07 pm by xuantruong1911
» mình đang làm đồ án 1 cần làm mạch khó số điện tử dùng ic số và phải có thể thay đổi password
Fri Mar 21, 2014 8:01 pm by saobang
» Chế tạo máy dò kim loại help ?
Fri Nov 29, 2013 11:17 am by Thanhtra conan
» mấy bro vào giup em với
Wed Nov 27, 2013 9:01 pm by luongthanhvp
» giáo trình plc mitsubishi căn bản và nâng cao
Tue Apr 30, 2013 5:55 pm by Admin
» hoc led chay chu
Thu Apr 18, 2013 8:05 pm by vuphong
» QUÉT PHÍM MA TRẬN 4X4 HIỂN THỊ RA LED 7 ĐOẠN
Thu Apr 18, 2013 7:59 pm by thanhxuan
» cách vẽ mạch in bằng ocard 1 cách đơn giản?
Thu Apr 18, 2013 1:09 pm by Admin