Hello Roy,
Working this way the point can occur outside the polyline for the search loop. This should not happen to me.
The solution that I would use:
Call the (inters) function with nil as the 5th argument.
If an intersection is found check the intersection with:
(equal ptFound (vlax-curve-getclosestpointto polylineObj ptFound T) 1e-8)