I want to write an if then in field calculator that tests if a field in the attribute table contains one of several versions of another string (the versions vary by capitalization).
Trouble is, I can't get even a simple if then to work, let alone an if then else if, which i would need here. I'm getting a 9999 error when I try the following:
(in the pre-logic script code)
Dim onlorain as Long
If InStr( [Export_Output.std],"Lorain" )>0 Then
onlorain = 1
else onlorain = 0
end if
(in the variable = ('parcel.onlorain =') box)
onlorain
I've posted a screenshot here:
I'd thought that ultimately, I'd be striving (when I build in the capitalization variants) for something like
Dim onlorain as Long
If InStr( [Export_Output.std],"Lorain" )>0 Then
onlorain = 1
elseif InStr( [Export_Output.std],"LORAIN" )>0 tHEN
onlorain = 1
elseif InStr( [Export_Output.std],"lorain" )>0 tHEN
onlorain = 1
else
onlorain = 0
end if
But if the 'simple', 1st version of this won't work, this won't work either.
Hope someone has thoughts.
Thanks in advance!
Best Answer
Here's a solution that should work. It also uses the UCase function that will convert your text to uppercase, so you don't have to check for all variants
You'll also put "output" into the lower box
EDIT
Here's another test using joined data like in your original case.