Hello, I'm a newbie to VBA Script, so any of the below script could be wrong. I'm trying to use Field Calculator to replace any "_10" at the end of a filename (i.e. an entry in a field, in an attribute table) with "_11". Could anyone help me please? Many thanks in advance! sdrew1
Pre-logic VBA Script Code
Dim MyStr as string
Dim strLen as integer
strLen = Len([FILENAME])
If Right([FILENAME],3) = "_10" Then
MyStr = Left([FILENAME], strLen-3)) & "_11"
Else
MyStr = [FILENAME]
End if
Filename =
MyStr
Solved! Go to Solution.
Ah great, thanks very much! Good to see the Replace function written out, thats informative!
A simple find and replace couldn't be used here?
Hi Joe, Thanks for reply. I did consider that but I didn't want it to get rid of the '_100' or '_210' so I thought it might be easier the alternative route. Sorry, you weren't to know that there might be '210' etc as an alternative. Cheers again.
My mistake; just re-read the original post and I was thinking attribute value and you are renaming files.
No problem - thanks for posting.