[GIS] ArcGIS field calculator: VBScript get data from previous row

field-calculatorindexingvbscript

When using the field calculator, how do I get data from the previous row in VBScript? In Python I'd do something like this:

for index, row in enumerate(rows,start=1):
    row[index-1] += 5

I'm using ArcGIS 9.3.1.

Let's assume I have a column [Distance] and all it's rows are 0. How do I increment every row with 5 starting at row 1. So the first row remains 0, second row'll be 5, third 10 and so on.

Best Answer

This script is from the Easy Calculate 5.0 Scripts by Ianko Tchoukanski

This section goes in the code block. Set the lInterval and lStart values as necessary. In this case, lInterval = 5 and lStart = 0.

Static rec As Long
Static i As Long
Dim lStart As Long
Dim lInterval As Long
'=================
'adjust start value and interval below
lStart =  0
lInterval = 5
'=================
If (i = 0) Then
  rec = lStart
Else
  rec = rec + lInterval
End If
i = i + 1

Place this in the [Field Name] = area:

rec
Related Question