HowTo:  Capitalize the first letter of a text or string field in ArcGIS Desktop 10.x

相关信息
Article ID: 40540
Software:
ArcGIS - ArcEditor 10
ArcGIS - ArcInfo 10
ArcGIS - ArcView 10
ArcGIS for Desktop Advanced 10.1
ArcGIS for Desktop Standard 10.1
ArcGIS for Desktop Basic 10.1
Platforms:
Windows XP, Server 2003, Vista, Server 2008, Windows 7

问题描述
Instructions provided describe how to use the Field Calculator in ArcMap to capitalize the first letter of all the values of a text or string field in an attribute table.



This workflow and code sample only works for versions 10.x or later. This is because ArcGIS no longer supports VBA at Version 10. For 9.3.1 and earlier, please see the link in the Related Information section.

已邀请:

EsriSupport

赞同来自:

解决方案
  1. In ArcMap, open the attribute table of a layer by right-clicking the layer in the Table of Contents and clicking Open Attribute Table.
  2. Right-click a field heading of a field that is to be edited. Click Field Calculator.
    Optionally, create a new text field for the result by clicking the Options button in the top left of the attribute table and selecting Add Field.
  3. When the Field Calculator window appears, choose VB Script as the Parser type and select Show Codeblock.
  4. Copy the following code into the Pre-Logic Script Code box.
    Dim sUpperC sUpperC = LEFT( [FIELD_NAME], 1)Dim sLowerC sLowerC = RIGHT( [FIELD_NAME], LEN( [FIELD_NAME]) - 1)Dim Output Output = UCASE(sUpperC) & sLowerC
  5. In the code, change [FIELD_NAME] to the name of the field in which to capitalize the first letter.
  6. Beneath the Pre-Logic Script Code box is another box labeled with the field name chosen in Step 5, followed by "=". In this box type "Output". In the image below it is TextList =.
  7. Click OK.


其它相关参考
  1. HowTo: Capitalize the first letter of a text or string field
  2. Desktop Help 10.0 - Fundamentals of field calculations


创建及修改时间
Created: 8/29/2012

Last Modified: 7/10/2013
原文链接
http://support.esri.com/en/kno ... 40540

要回复问题请先登录注册