Calculate distance between consecutive points

Discussion created by Karren.O on Mar 6, 2014
Latest reply on Mar 19, 2014 by rfairhur24
I wish to calculate the distance between consecutive points in a feature class.
I tried using the following code in the "Pre-Logic VBA Script Code" box in the Field Calculator dialog -

static x0 as double, y0 as double ' Previous location
dim pPoint as IPoint
set pPoint = [Shape]

x = pPoint.X
y = pPoint.Y
d = sqr((x - x0)^2 + (y - y0)^2) ' Distance
x0 = x
y0 = y

but it doesn't work. Does anyone have any suggestions? Thanks for any help anyone can give me.