PDA

View Full Version : Trig functions

Barry Clark
24th Mar 2005, 09:07 pm
I am starting to use trig functions in my routines and I have hit a bump.

Any help in what I am doing will be greatly appeciated.

Where I think my problem is occurs at converting the input to usable data for the math. I just wasn't able to find where I could get the Dim argument and the Set argument to agree.

Sub PCoords&#40;&#41;
Dim A As String, D As String
Dim X As String, Y As String
A = ThisDrawing.Utility.GetString&#40;False, "Enter angle &#40;degrees&#41;&#58; "&#41;
D = ThisDrawing.Utility.GetString&#40;False, "Enter distance &#58; "&#41;
A = A * &#40;pi / 180&#41;
X = D * Cos&#40;A&#41;
Y = D * Sin&#40;A&#41;
MsgBox X & ", " & Y
End Sub

Any help would be greatly appreciated. Thanks!

devitg
14th Apr 2005, 04:04 pm
I do not know nothing about the VBA

Could you handle string as values in a formula????
Maybe yiou have to change from string to numbers :oops:

hendie
15th Apr 2005, 08:23 am
step through your code and watch the value of A

where have you declared pi ?

Sub PCoords&#40;&#41;
Dim A As Double, D As Double
Dim X As Double, Y As Double
Dim Pi
Pi = 4 * Atn&#40;1&#41;

A = ThisDrawing.Utility.GetAngle&#40;, "Enter angle &#40;degrees&#41;&#58; "&#41;
D = ThisDrawing.Utility.GetDistance&#40;, "Enter distance &#58; "&#41;
A = A * &#40;Pi / 180&#41;
X = D * Cos&#40;A&#41;
Y = D * Sin&#40;A&#41;

MsgBox "X= " & X & ", " & "Y= " & Y
End Sub

devitg
15th Apr 2005, 11:37 am
Hendie, you changed the variable to DOUBLE , as I supposed it should be.
I miss about the PI , the first error did not allow me to see the other.

As I told before, I do not know nothing about VBA, could you route me or explain how it is used in acad???? :roll:

hendie
15th Apr 2005, 11:53 am
... could you route me or explain how it is used in acad????

I'm not sure I understand what you mean ~ can you try and exaplain a bit more please ?

if you mean how can it be applied in Autocad, take a look at a couple of my programs on http://www.resourcecad.com/ ~ the Block Isolation utility and the Cone Development Tool are both written in VBA