Hey is what you need, this is from the "Conversational Wizard" I put up but the code in it will work for you, just modify it for your situation:
Sub Main()
'G68 angle calc
SetUserLed(1039,1)
x1=GetUserDRO(1081)
y1=GetUserDRO(1082)
x2=GetUserDRO(1095)
y2=GetUserDRO(1096)
D=1
pi = 4 * Atn(1)
If x2-x1=0 Then
Message("X2 cannot = X1!!")
Exit Sub
End If
If y2-y1=0 Then
Message("y2 cannot = y1!!")
Exit Sub
End If
If y2=0 Then
Message("y2 cannot = 0!!")
Exit Sub
End If
If x2=0 Then
Message("X2 cannot = 0!!")
Exit Sub
End If
If y2>y1 And x2>x1 Then
D=D*1
End If
If y2>y1 And x2<x1 Then
D=D*-1
End If
If y2<y1 And x2<x1 Then
D=D*1
End If
If y2<y1 And x2>x1 Then
D=D*-1
End If
a=y2-y1
b=x2-x1
ang=(180/pi) * Atn(a/b)
If D>0Then
SetUserDRO(1094,ang)
End If
If D<0Then
SetUserDRO(1094,ang)
End If
End Sub
Main
'scott