Select to view content in your preferred language

Text String Script

1057
6
03-22-2012 07:13 AM
CaraMays
Deactivated User
I am trying to write a script that will trim my acreage two places after the decimal. Any help would be appreciated!
Tags (2)
0 Kudos
6 Replies
ChristopherThompson
Frequent Contributor
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.
0 Kudos
CaraMays
Deactivated User
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!
0 Kudos
CaraMays
Deactivated User
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.
0 Kudos
DanEvans
Frequent Contributor
Hi,

The field calculator expression you want is something like:

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
0 Kudos
CaraMays
Deactivated User
Thank you!!!! 🙂
0 Kudos
GeorgiaHalsted
Emerging Contributor
good idea,good luck man
0 Kudos