Aaryan,
maybe not a very clean way to solve the problem but the "vlax-curve-getClosestPointTo" function sometimes does not work well, when the object is not orthogonal,
so the way I got to get around this situation is to calculate twice the closest point on the curve, so the second point is on the curve and therefore already calculates the distance on the curve without error,
(setq a (car (entsel "\nSelect Line:")))(setq b (getpoint "\nPick Point"))(setq c (vlax-curve-getDistAtPoint a (vlax-curve-getClosestPointTo a (vlax-curve-getClosestPointTo a b T) T)))
test your code by rotating your line to the vertcal and to the horizontal, and see that the
"vlax-curve-getClosestPointTo" function works well if the object is orthogonal.