Rather than confuse things by embedding your critical code in a scan procedure, use GetElementByID to get Element1 and Element2. Then pass those to a function that computes an intersection...
Dim line1 As LineElement
Dim line2 As LineElement
Set line1 = GetElementByID (530)
Set line2 = GetElementByID (999)
ComputeIntersections (line1, line2)
Function ComputeIntersections (line1 As LineElement, line2 As LineElement) As Boolean
ComputeIntersections = False
If ( ... your test here ...) Then
ComputeIntersections = True
End If
End Function
Once that works you can substitute the working function into your scan procedure.
Regards, Jon Summers
LA Solutions