Macro help for right angle diagram.
I am using macros to show the components of a right angle diagram. So far I can input an angle and generate the cosine of the angle, then enter a value for the Hponenous and I can get the total of the horizontal but then I have to use Pythagorean Theorem to solve for the side opposite. Im sure there is an other way to do the side opposite.
Here is my script thus far:
Private Sub angle_Change()
If Not IsNumeric(Me.angle) And Len(Me.angle) > 0 Then Me.angle.Text = Left(Me.angle, Len(Me.angle) - 1)
If Val(Me.angle) < 0 Then Me.angle.Text = "0"
If Val(Me.angle) > 90 Then Me.angle.Text = "90"
End Sub
Private Sub angle_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Me.pfactor.Text = Cos(Val(Me.angle) / 57.29578)
pfactor = Round(pfactor, 3)
End Sub
Private Sub ind_Change()
If Not IsNumeric(Me.ind) And Len(Me.ind) > 0 Then Me.ind.Text = Left(Me.ind, Len(Me.ind) - 1)
If Val(Me.ind) < 0.0001 Then Me.ind.Text = ".0001"
If Val(Me.ind) > 1000 Then Me.ind.Text = "1000"
End Sub
Private Sub ind_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Me.indx.Text = 2 * 3.14159265358979 * 60 * Val(Me.ind)
indx = Round(indx, 3)
Me.indh.Text = Val(Me.indx) * Val(Me.pfactor)
indh = Round(indh, 3)
Me.indv.Text = Sqr((Val(Me.indx ^ 2)) - (Val(Me.indh ^ 2)))
End Sub
Any suggestions would be greatly appreciated.
|