HOW TO
These instructions provide examples of VBScript and Python syntax that show a way to calculate fields where some input values are null.
Note: Be aware that the Python form of the script produces the expected results on 10.1, but on 10.0 does not return a value for null inputs. VBScript produces the correct results on both versions.
The calculation in each case applies the source value (in this case, the field Dbl1 or Dbl2) to the target field unless the source is null, in which case the target field is assigned the value zero.
VBScript:
Code: Dim X if IsNull ([Dbl1]) then X = 0 else X = [Dbl1] end if __esri_field_calculator_splitter__ X
Python:
Code: def X (param): retVal = 0 if param is not None: retVal = param return retVal __esri_field_calculator_splitter__ X (!Dbl2!)
See the following illustrations of a table before and after each field calculation. In the table, field Dbl1Calc was calculated using the sample VBScript code. Field Dbl2Calc was calculated using the sample Python code.
Before
After
Article ID:000011840
Get help from ArcGIS experts
Download the Esri Support App