To solve the distance on a pline you can build a 2D array containing the infomation of length, starting/ending points' coordinates, center coordinates, buldge etc. for each segment in the pline. And, the 2D array variable should be made public variable. I call it SegArray().
The attached is the my trail version. It can measure the length along a pline between any two given points. Bugs may occur when analyzing a curve. However, this program shows one option to solve the problem.
Good luck.
Eddy Yang