Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-26-2012, 04:09 PM
Jamtart Jamtart is offline Macro help for right angle diagram. Windows 7 64bit Macro help for right angle diagram. Office 2010 64bit
Advanced Beginner
Macro help for right angle diagram.
 
Join Date: Apr 2012
Posts: 53
Jamtart is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 08-26-2012, 07:08 PM
Jamtart Jamtart is offline Macro help for right angle diagram. Windows 7 64bit Macro help for right angle diagram. Office 2010 64bit
Advanced Beginner
Macro help for right angle diagram.
 
Join Date: Apr 2012
Posts: 53
Jamtart is on a distinguished road
Default

Ok, cruising right along. Cant get one more item at all. I have created a rt angle triangle, I divided the side adjacent by the Hypontenous, which gives you the Cosine. How can I convert this into an angle? For example, a cosine of .866 is 30 degrees.
Reply With Quote
  #3  
Old 08-27-2012, 01:51 AM
JohnWilson JohnWilson is offline Macro help for right angle diagram. Windows 7 64bit Macro help for right angle diagram. Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

PowerPoint doesn't have an ACos function (unlike Excel) which makes it difficult to get the Angle from a Cosine

You can write a User defined function though (hope your math is good!).

Code:
Function GetAngle(ThisCos As Double) As Double
Const PI As Double = 3.141592
Dim Acos As Double
Acos = Atn(-ThisCos / Sqr(-ThisCos * ThisCos + 1)) + 2 * Atn(1)
GetAngle = Round(Acos * 180 / PI, 2)
End Function
From your normal code you would use this :

Code:
Dim theAngle As Double
theAngle = GetAngle(0.866)
MsgBox theAngle
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #4  
Old 08-27-2012, 06:35 AM
Jamtart Jamtart is offline Macro help for right angle diagram. Windows 7 64bit Macro help for right angle diagram. Office 2010 64bit
Advanced Beginner
Macro help for right angle diagram.
 
Join Date: Apr 2012
Posts: 53
Jamtart is on a distinguished road
Default

Works perfect John. Would have been so much easier if PPT had the ACOS like excel, found that out in my readings trying to find a solution.
So I guess using Pythagorean Theorem (Me.indv.Text = Sqr((Val(Me.indx ^ 2)) - (Val(Me.indh ^ 2)))) in my original post was indeed the easiest way to solve for the side opposite (Vertical component of the triangle) after all.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro help for right angle diagram. network diagram arrows ketanco Project 3 02-14-2013 10:46 AM
Macro help for right angle diagram. the angle format (º ‘ ‘’) and calculation? Jamal NUMAN Excel 25 05-19-2012 01:50 PM
Macro help for right angle diagram. how to draw line diagram with x yr yl gsrikanth Excel 1 03-07-2012 05:50 AM
arrows not showing in certain sections of network diagram ketanco Project 1 12-24-2011 12:50 PM
Angle Bracket Problem, STYLEREF in Header of a Protected Document wordjunkie Word 0 06-18-2010 04:34 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:17 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft