Blog Lê Trung Hiếu

Just another WordPress.com site

Ôn tập tin thi học kì-2

Tiếp tục ôn tập tiếp nào…(đề cương đã xong mỗi ngày post 1 tí )

Bài 3: Giao hội góc

B1:Tạo 1 form (Add/Form),1 module (Add/Module)

B2:Code

Form code :

Private Sub CmdThoat_Click()

Unload FrmGiaoHoiGoc

End Sub

Private Sub CmdTinh_Click()

Dim Xa As Double, Ya As Double

Dim Xb As Double, Yb As Double

Dim GocA As Double, GocB As Double

Dim Xc As Double, Yc As Double

Xa = Val(TxtXa.Text)

Ya = Val(TxtYa.Text)

Xb = Val(TxtXb.Text)

Yb = Val(TxtYb.Text)

GocA = Val(TxtGocA.Text)

GocB = Val(TxtGocB.Text)

GiaoHoiGoc Xa, Ya, Xb, Yb, GocA, GocB, Xc, Yc

TxtXc.Text = Format(Xc, “0.000”)

TxtYc.Text = Format(Yc, “0.000”)

End Sub

Module code

Public Sub GiaoHoiGoc(Xa As Double, Ya As Double, Xb As Double, Yb As Double, GocA As Double, GocB As Double, Xc As Double, Yc As Double)

Dim c As Double, b As Double, gocARad As Double, GocBRad As Double

c = TKC(Xa, Ya, Xb, Yb)

gocARad = DomsRad(GocA)

GocBRad = DomsRad(GocB)

b = (c * Sin(GocBRad)) / Sin(gocARad + GocBRad)

ToaDoCuc Xa, Ya, Xb, Yb, GocA, b, Xc, Yc

End Sub

Public Function TKC(X1 As Double, Y1 As Double, X2 As Double, Y2 As Double) As Double

TKC = Sqr((X2 – X1) ^ 2 + (Y2 – Y1) ^ 2)

End Function

Public Function Pi() As Double

Pi = 4 * Atn(1)

End Function

Public Function TPV(Xa As Double, Ya As Double, Xb As Double, Yb As Double) As Double

Dim Dy As Double, Dx As Double, Anfa As Double

Dy = Yb – Ya

Dx = Xb – Xa

If Dx = 0 Then

If Dy > 0 Then

TPV = Pi() / 2

Else

TPV = 3 * Pi() / 2

End If

Else

Anfa = Atn(Dy / Dx)

If (Dx > 0) And (Dy > 0) Then TPV = Anfa

If (Dx 0) Then TPV = Pi() + Anfa

If (Dx

If (Dx > 0) And (Dy

End If

End Function

Public Function DomsRad(goc As Double) As Double

Dim D As Integer, m As Integer, s As Integer

D = Fix(goc)

m = Fix((goc – D) * 100)

s = ((goc – D) * 100 – m) * 100

DomsRad = (D + m / 60 + s / 3600) * Pi() / 180

End Function

Public Sub ToaDoCuc(Xa As Double, Ya As Double, Xb As Double, Yb As Double, Gock As Double, Sk As Double, Xk As Double, Yk As Double)

Dim PVab As Double

PVab = TPV(Xa, Ya, Xb, Yb)

Gock = DomsRad(Gock)

Yk = Ya + Sk * Sin(PVab + Gock)

Xk = Xa + Sk * Cos(PVab + Gock)

End Sub

Bài 4: Giải phương trình bậc 2

B1:Tạo 1 form (Add/Form)

B2:Code

Form code :

Private Sub CmdThoat_Click()

Unload FrmGPT

End Sub

Private Sub CmdTinh_Click()

Dim a As Double ‘ Khai b¸o biÕn A kiÓu sè thùc

Dim b As Double, c As Double

Dim X1 As Double, X2 As Double

Dim Delta As Double

a = Va(TxtA.Text)

b = Val(TxtB.Text)

c = Val(TxtC.Text)

If (a = 0) Then

If (b = 0) Then

If (c = 0) Then

MsgBox ” pt vo so nghiem”

Else

MsgBox ” pt vo nghiem”

End If

Else

X1 = -c / b

X2 = X1

End If

Else

Delta = b ^ 2 – 4 * a * c

If (Delta

MsgBox ” Pt vo nghiem vi Detla <0"

ElseIf (Delta = 0) Then

X1 = -b / (2 * a)

X2 = X1

MsgBox ” pt co nghiem kep”

Else

X1 = (-b + Sqr(Delta)) / (2 * a)

X2 = (-b – Sqr(Delta)) / (2 * a)

End If

End If

TxtX1.Text = Format(X1, “0.00”)

TxtX2.Text = Format(X2, “0.000”)

End Sub

Gửi phản hồi

Mời bạn điền thông tin vào ô dưới đây hoặc kích vào một biểu tượng để đăng nhập:

WordPress.com Logo

Bạn đang bình luận bằng tài khoản WordPress.com Log Out / Thay đổi )

Twitter picture

Bạn đang bình luận bằng tài khoản Twitter Log Out / Thay đổi )

Facebook photo

Bạn đang bình luận bằng tài khoản Facebook Log Out / Thay đổi )

Google+ photo

Bạn đang bình luận bằng tài khoản Google+ Log Out / Thay đổi )

Connecting to %s

%d bloggers like this: