6 Replies Latest reply on Mar 26, 2012 11:18 PM by harold251

    Text String Script

    chaas_cc
      I am trying to write a script that will trim my acreage two places after the decimal. Any help would be appreciated!
        • Re: Text String Script
          clthompson
          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.
          • Re: Text String Script
            chaas_cc
            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!
            • Re: Text String Script
              chaas_cc
              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.
              • Re: Text String Script
                DanEvans83
                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
                • Re: Text String Script
                  chaas_cc
                  Thank you!!!! :)
                  • Re: Text String Script
                    harold251
                    good idea,good luck man