Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

From time to time, I have to use Visual Basic in Calculate field.

As the code get bigger, the more complicated is to debug it. And ArcGIS (9.3) does not help as the error messages are, in the best cases, something like:

"A field name was not found or there were unbalanced quotation marks.
ERROR 999999: Error executing function.
Failed to execute (Calculate Field)."

It's not very informative, has an ambiguous reference to the type of error and does not say the line of the code where the error occurred.

So my question is: Is there a better way to debug the code in ArcGIS? Anyone has strategies to share, or a parallel software or site to do it?

Thanks

share|improve this question
1  
I have had some success prototyping complex VBA expressions as Excel macros and using its debugging facilities :-). –  whuber Sep 7 '12 at 17:56
3  
I would suggest learning and using Python instead. That way you can write and debug your functions in PyScripter or another decent IDE and either import or copy/paste them into the field calculator. If you need to use ArcObjects then this approach gets more complicated, though you could use comtypes there. –  blah238 Sep 7 '12 at 18:13
    
Thank you for your answers. They were all usefull. –  Alexandre Neto Sep 10 '12 at 8:54
add comment

1 Answer 1

up vote 1 down vote accepted

Since you are using version 9.3 you can use VBA for very complex scripts and the immediate window for complex single-line expressions. Just create a procedure or a function in VBA and instead of field values set up variables of the same data type and assign them representative dummy values. You can then run the function or step through it line by line and examine each value.

For simpler "one-line" expressions you can open VBA paste the expression into the immediate window and run it. You will also have to declare variables with dummy values but you can do that prior to running your expression directly in the immediate window. I would use this approach when concatenating values from several fields, using mid, instr, len, trim, etc.

share|improve this answer
    
Thanks you for your answer. That was what I need. The Obvious part that I was missing was the use of dummy values to properly test it. –  Alexandre Neto Sep 10 '12 at 8:57
add comment

Your Answer

 
discard

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.