+ Reply to Thread
Results 1 to 7 of 7

Thread: Text String Script

  1. #1
    Cara Mays
    Join Date
    Oct 2010
    Posts
    16
    Points
    1
    Answers Provided
    0


    0

    Default Text String Script

    I am trying to write a script that will trim my acreage two places after the decimal. Any help would be appreciated!

  2. #2
    Christopher Thompson
    Join Date
    Apr 2010
    Posts
    239
    Points
    121
    Answers Provided
    19


    0

    Default Re: Text String Script

    Can you provide a little more information about your problem? Where are these acreages being stored and retrieved from? What is it you are trying to do that you need to change the precision of that number to 2 digits right of the decimal? The context of this problem helps me to to understand what sort of advice to give you.

  3. #3
    Cara Mays
    Join Date
    Oct 2010
    Posts
    16
    Points
    1
    Answers Provided
    0


    0

    Default Re: Text String Script

    Yes, I have stored my aguse information in a geodatabase. I have added a field in which I would like to calculate total acreage in a section and provide a report with the total acreage of a certain land use feature. Once I have added a new field and calculated the acreage, the number has 12 or 13 numbers after the decimal. For example, acreage = 123.236545231236. Here, I would like to use the Calculate Geometry tool to perform a "trim" of the number where all the attributes will be trimmed to two decimal places.

    Is this enough? Sorry if this is a little confusing. Thanks for your help!

  4. #4
    Cara Mays
    Join Date
    Oct 2010
    Posts
    16
    Points
    1
    Answers Provided
    0


    0

    Default Re: Text String Script

    I am sorry, I used the Calculate Geometry to find the acreage...Now I would like to use the Field Calculator to trim the decimal places.

  5. #5
    Dan Evans
    Join Date
    Apr 2011
    Posts
    82
    Points
    40
    Answers Provided
    5


    1

    Default Re: Text String Script

    Hi,

    The field calculator expression you want is something like:

    Code:
    Round( [Acreage] , 2)
    Where [Acreage] is the field with the acreage in, and the 2 is the number of decimal places to round to. That's for VBA if you're using 9.3, I think VBScript in 10 is the same.

    Python is the same function Round() but I think you put exclamation points around the field name rather than square brackets e.g. !Acreage! instead of [Acreage].

    Hope that helps...

    Dan

  6. #6
    Cara Mays
    Join Date
    Oct 2010
    Posts
    16
    Points
    1
    Answers Provided
    0


    0

    Default Re: Text String Script

    Thank you!!!!

  7. #7

    Join Date
    Mar 2012
    Posts
    4
    Points
    1
    Answers Provided
    0


    0

    Default Re: Text String Script

    good idea,good luck man

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts