Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can't get the syntax correct for a fairly simple if statement. Right now it looks like this:

dim Output as Integer
If [HECTARES] >= 30 AND [HEIGHT] >= 17 AND [CROWN] >= 59
 THEN Output = 1
 ELSE Output = 0

I have no idea whether that's the correct use of "AND" but the expression wouldn't evaluate with only one expression (i.e. [HECTARES] > 30) either.


share|improve this question

Try this under the Field Calculator advanced option.

Dim Output as Integer 
If [HECTARES] >= 30 AND [HEIGHT] >= 17 AND [CROWN] >= 59  Then
Output = 1

Output = 0 
end if

I've gotten this syntax to work with my data.

share|improve this answer
That would be a terribly silly bug on ESRI's part, if this works. White-space parsing issues shouldn't cause a syntax error. – Michael Todd Nov 4 '10 at 20:39
@Michael You would enjoy the Raster Calculator in ArcGIS 9.x, then: most operators required surrounding whitespace for the parser to succeed. "Silly" isn't the word for it... – whuber Nov 5 '10 at 2:45

I am assuming that you are using ArcGIS 10 and not 9.x.

According to the Calculate Field help file, in ArcGIS 10:

VBScript does not allow you explicitly declare any data types; all variables are implicitly Variant. Statements like Dim x as String should be removed or simplified to Dim x.

This worked for me in Arc 10:


Dim output
IF [HECTARES] >= 30 and [HEIGHT] >= 17 and [CROWN] >= 59 THEN
Output = 1

Field =


Basically, just remove "as Integer" and it will actually work on 9.3 as well.

share|improve this answer
Thanks Jason (and everyone else). Your version of the expression works fine. Though oddly the problem doesn't seem to be the explicit declaration of the data type as you code also works if I add in "as integer". The problem appears to be my expression parsing (e.g. using "Then Output = 1" rather than – Phil Greyson Nov 5 '10 at 11:53
My comment got timed out, hence the second part. I didn't have carriage returns in the correct places. Thanks again everyone. – Phil Greyson Nov 5 '10 at 11:55

Assuming that this is in a file geodatabase, enclose the field in "" - double quotes, for shapefile i think it's also double quotes. Each uses different "field" enclosure. If the expression passes validation, check for Null values. Also make sure the field is numeric (as was already mentioned)

share|improve this answer
This is more appropriate as a comment. – Derek Swingley Nov 4 '10 at 20:28
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. – AndreJ Aug 18 '15 at 19:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.