The Sine Rule

 

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

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)

X = (3.14159 / 180) * A
Y = (3.14159 / 180) * B

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

Lbl_Answer.Caption = Str(Format(d, "0.00"))


End Sub
 

 

 

 

[Back to Sample VB Programs]