English

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

Summary

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 either 'Open Attribute Table' or 'Open' 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:

    Code:
    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.