English

How To: Extract characters from a string field to a new field using a space as a delimiter

Summary

Note: 
The information in this article applies to ArcGIS version 9.x only. Visual Basic for Applications (VBA) for ArcMap and ArcCatalog has been deprecated at ArcGIS 10.

Instructions provided describe how to extract characters from a string field to a new field using a space as a delimiter. This article contains a code sample that extracts all characters to the left of the first space and pastes them into another field.

Procedure

Follow the steps below:

  1. Click Editor on the Editor toolbar and click Start Editing.
  2. Right-click the layer or standalone table in the Table of Contents and click Open Attribute Table.
  3. Right-click the field heading for the field in which the extracted characters are stored. Click Calculate Values.
  4. Click on the Advanced checkbox.

    [O-image] Field Calculator
  5. Type the following VBA statement in the first text box:
    dim space as integer
    space = instr([name], " ")
    dim var as string
    var = left([name], space)

    Change [name] in lines 2 and 4 to the source field name.
  6. Type the variable var in the text box directly under the area field name.
  7. Click OK.