Public Function CalculateLineAngle(ByVal vStartPoint As Variant, ByVal vEndPoint As Variant) As Double On Error Resume Next
Dim X As Double Dim Y As Double
X = vEndPoint(0) - vStartPoint(0) Y = vEndPoint(1) - vStartPoint(1) If (X > 0 And Y > 0) Or (X > 0 And Y < 0) Then CalculateLineAngle = Atn(Y / X) If (X < 0 And Y > 0) Or (X < 0 And Y < 0) Then CalculateLineAngle = PI + Atn(Y / X) If X = 0 Then If Y < 0 Then CalculateLineAngle = -PI / 2 If Y > 0 Then CalculateLineAngle = PI / 2 End If If Y = 0 Then If X < 0 Then CalculateLineAngle = PI If X > 0 Then CalculateLineAngle = 0 End If If Abs(CalculateLineAngle - 0) < dbJudgeAngle Then CalculateLineAngle = 0 If CalculateLineAngle < 0 Then CalculateLineAngle = 2 * PI + CalculateLineAngle