VB2019 VB2017 VB2015 VB2013 VB2012 VB2010 VB2008 VB6 VB Sample Codes 中文VB About Us

The Sine Rule



Can you still remember your high school mathematics? We are sure you have learned the famous Sine Rule. Using the Sine Rule, you can calculate angles and any side of the triangle if you are given enough data. The sine rule is shown in the diagram below. For example, if the user enters angle A and angle B as 60 and 30 respectively, and the length a=4,b=6.93, you can calculate c. You need to convert the degree to radian by multiplying the angle by pi(=3.14159) and divide it by 180.

The Interface

The Code

Private Sub Cal_Click()
Dim A, B, l, X, Y, d As Single
A = Val(Txt_angleA.Text)
B = Val(Txt_angleB.Text)
l = Val(Txt_sideA.Text)

'To convert the angle to radian
X = (3.14159 / 180) * A
Y = (3.14159 / 180) * B

d = l * Sin(X) / Sin(Y)

'To correct the answer to two decimal places
Lbl_Answer.Caption = Str(Format(d, "0.00"))

End Sub


 


Copyright©2008 Dr.Liew Voon Kiong. All rights reserved |Contact|Privacy Policy