Given a line: (x1,y1)-(x2,y2)
given a line; (x1,0)-(x2,100)
how can i find the angle of these 2 lines?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

It's difficult to give a definite answer to this question without knowing the coordinate system you are using.  However, in general the angle of a line is calculated as:

Radians = ArcTangent( (Y2-Y1) / (X2-X1) )

From the help:
The Atn function takes the ratio of two sides of a right triangle (number) and returns the corresponding angle in radians. The ratio is the length of the side opposite the angle divided by the length of the side adjacent to the angle.

The range of the result is -pi/2 to pi/2 radians.

To convert degrees to radians, multiply degrees by pi/180. To convert radians to degrees, multiply radians by 180/pi.
Example code:

'''Picture1.ScaleMode = 3 'Pixel
Dim X1, X2, Y1, Y2 As Double
Dim mPI As Double
Dim angle As Double
mPI = 4 * Atn(1) 'define PI
X1 = 0
Y1 = 0
X2 = 10
Y2 = 100
Picture1.Line (X1, Y1)-(X2, Y2) 'Draw the line
If X2 <> X1 Then 'Prevent division by 0
    'Calculate angle
    angle = Atn((Y2 - Y1) / (X2 - X1)) * (180 / mPI)
    angle = 90
End If
Debug.Print angle

You will have to adjust the sign of the angle depending on your coordinate system.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.