You are here: > ESRI Forums > arcgis desktop discussion forums > Thread Replies

ArcGIS Desktop Discussion Forums

ArcGIS Desktop - Attribute Tables forum

Field Calculator String Trim   Patricia Moehring Aug 26, 2009
Re: Field Calculator String Trim   Henry Kovacs Aug 26, 2009
Re: Field Calculator String Trim   Alejandro Tongco Oct 08, 2009
Re: Field Calculator String Trim   Joshua Crough Aug 26, 2009
Re: Field Calculator String Trim   Richard Hardin Aug 26, 2009
Re: Field Calculator String Trim   Patricia Moehring Aug 27, 2009
Re: Field Calculator String Trim   Matthew Toro May 06, 2010
Re: Field Calculator String Trim   Matthew Toro May 06, 2010
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Field Calculator String Trim 
Author Patricia Moehring 
Date Aug 26, 2009 
Message I have a field that has a "\" character at the beginning of the string and I cannot get rid of it or replace it. I've attempted Trim but get a vba error. LTrim and RTrim don't give me the results I'm looking for. I know this can be done! Anyone out there know how? Thanks, Patricia 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Field Calculator String Trim 
Author Henry Kovacs 
Date Aug 26, 2009 
Message LTrim and RTrim will only remove trailing spaces. What you need to use is the Right() function. First, create a field called Length and use the Len() function. This will calculate the number of characters in the field that you are working with. Then create a second new field. Use the following calculate statement in the second new field and you should get what you need.

Right ( [Name of Original Field Here], [Length] -1 )

I realize I was pretty brief. Hopefully that all makes sense. Let me know if it doesn't. Tomorrow I will have more time if you have questions.

good luck. 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Field Calculator String Trim 
Author Alejandro Tongco 
Date Oct 08, 2009 
Message Henry K,

Clever!

(I encountered similar problem trying to trim 3 characters off the right end of a string. RTrim doesn't work.)

Thanks a lot,

Al 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Field Calculator String Trim 
Author Joshua Crough 
Date Aug 26, 2009 
Message When you tried to replace it did you use REPLACE([FIELDNAME], "/","") cause this should do the trick too.

Cheers,

Joshua 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Field Calculator String Trim 
Author Richard Hardin 
Date Aug 26, 2009 
Message You can also use the Mid function and specify the second character as the starting position...

Mid("FieldName",2)

or the Replace function if you want to change it to something else.

cheers 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Field Calculator String Trim 
Author Patricia Moehring 
Date Aug 27, 2009 
Message Thanks to all! OMG, I used the mid function and it worked perfectly! So easy when you know what you are doing!!!! Thanks again to all!) 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Field Calculator String Trim 
Author Matthew Toro 
Date May 06, 2010 
Message A related question:

I have a field of addresses -- let's call it [ADDRESS] -- whose 16 last letters/digits must be removed.

For example:

12345 Oak Ln : XXXXXXXXXXXXXXXX
98765 Castle St : XXXXXXXXXXXXXXXX
645 Happy People Rd : XXXXXXXXXXXXXXXXX

I want to cut out those last 18 letters/digits, beginning at the colon ":".

I've used the InStr function to determine where the colon ":" begins on each field. I've created a new field -- let's call it [InStr] -- containing the numeric value of where the colon begins in every record.

I want to calculate a new field -- let's call it [ADDRESS] -- with only the addresses, without everything from the colon onwards. I was hoping that I could simply use the following VBA function:

Left ([ADDRESS], [InStr] -1 )

But, as I'm sure you already know, it didn't work.

Can anybody help? Thanks in advance!!!

Matthew


 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Field Calculator String Trim 
Author Matthew Toro 
Date May 06, 2010 
Message Clearly some serious typos here:

Let's call the first field [NAME], the second field [InStr], and the third field [ADDRESS].

And obviously I meant 18. Thanks again!