0

Using the field calculator of ArcMap, I know I need to use a text qualifier "" for string, and if numbers are in a text field (at least for VB Script which is what we are learning in).

Is there a specific reason for this and why don't you have to use it for numeric fields?

1
  • If you have the choice, I would say it is better to learn Python.
    – Bera
    Commented Oct 18, 2022 at 6:06

1 Answer 1

2

This is entirely due to the syntax of the programming language you are using (in this case VB Script, but it is much the same for other - eg, in Python, you can use either " or ').

The value that you enter in the 'Expression' parameter in the field calculator is really just an expression (sort of a one-line program) in your programming language of choice. In the vast majority of programming languages, a number is interpreted literally as a number, a " or ' delimited string of text is interpreted a literal text and anything else is either a reserved word (ie, a word which has a special meaning in the language), a variable or function name, or an operator (eg, +, -).

So in most languages, "16" is not a number, but a text string represented by two characters of text (and likely stored as two ACII or Unicode representations of those characters). But 16 is actually a number and is stored as the binary representation of that number, not a text encoding of the two digit characters.

In programming languages, types matters. Number values (eg, int, real, double, float) are treated completely differently to text string values.

You can use either text or numbers in the Field Calculator expression, but in some contexts, the result will be different depending on what you do with them. Eg, In most languages, "16" + "4" is completely different to 16 + 4. (I'm not familiar with VB Script, preferring Python, but I think that in VB Script the + operator will actually cause the string values to be re-interpret as numbers, so the result may actually end up the same in this example?)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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