[GIS] Using VBA in ArcMap field calculator

arcgis-desktopfield-calculatorvba

I am trying to use ArcMap's Field Calculator to populate values in a column based on a value in another column. So, in pseudo-code:

if [field1] = 'Foo'
  set [field2] = 'Bar'
endif

Something like that. Test for 'foo' in the first attribute, and set the record's second attribute to 'bar.' Seems like it should be pretty easy to do, but I keep receiving a "user interrupt" error every time I try running anything. I think I have a misunderstanding of how to build VBA expressions with the Field Calculator…

Best Answer

Try something like this:

dim f2
if [field1] = "foo" then
  f2 = "bar"
end if

Screen shot of this being used in the field calculator.alt text

Related Question