Calculate Field: VB Code Block

848
7
11-10-2009 07:05 AM
AdrianBirch
New Contributor
I can't get the Calculate Field GP tool to work where I'm using a VB script code block. I also notice that the Code Block option in the Field Calculator (launched directly from an attribute table) is disabled for VB Script.

Can you clarify what the position is with this - is VB script no longer supported in Calculate Field (in favour of Python)?
0 Kudos
7 Replies
JeffMoulds
Esri Contributor
For 94 beta1, code blocks are not supported for VbScript in the GP CalculateField tool or by right clicking a field in TableView. That is due to the deprecation of VBA of 94. At 93, multiline VB code blocks were actually parsed by VBA, and the single line expression parameter was parsed by VbScript. We do however still support VbScript at 94; but it still only for the single line expression parameter. We are currently investigating VbScript code blocks for 94 to support 93 workflows. For your records, the tracking number to support multiline code blocks in NIM050827.

At beta1, you have to use Python for complex code blocks.

Please let me know if you have any questions about this, or if you run in to any other problems with the 94 field calculator; especially any issues with transitioning 93 workflows to 94.
0 Kudos
KevinKuhn
New Contributor III
I am trying to enter in a value to a selected set of features via field calculator and nothing happens. 

I have also noticed some oddities, such as the att table does not open at all (locks up) or I have to resize the bottom of the frame and then it appears. 

I have also tried to add a new field, and it says it is in use by another application (not true).  This is just a point shp file, about 160k features.  I was able to eventually create a new field and calculate other values for it... but 9.4 seems to not like something.  (same data worked fine in 9.3)

UPDATE:  as a hunch, I tried using a definition query to 'select out' the features I wanted to calculate values for and then tried it... low and behold it worked.  so, seems like there is a conflict to having features selected and trying to use a field calculator on them.... 

thoughts ??
0 Kudos
TedCronin
MVP Honored Contributor
For 94 beta1, code blocks are not supported for VbScript in the GP CalculateField tool or by right clicking a field in TableView. That is due to the deprecation of VBA of 94. At 93, multiline VB code blocks were actually parsed by VBA, and the single line expression parameter was parsed by VbScript. We do however still support VbScript at 94; but it still only for the single line expression parameter. We are currently investigating VbScript code blocks for 94 to support 93 workflows. For your records, the tracking number to support multiline code blocks in NIM050827.

At beta1, you have to use Python for complex code blocks.

Please let me know if you have any questions about this, or if you run in to any other problems with the 94 field calculator; especially any issues with transitioning 93 workflows to 94.


So, there is a possibility that at 94 final, we could do more complex vbscript?
0 Kudos
JeffMoulds
Esri Contributor
So, there is a possibility that at 94 final, we could do more complex vbscript?


Yes, the plan is to support multiline VbScript code blocks at either beta2 or final.
0 Kudos
JeffMoulds
Esri Contributor
I am trying to enter in a value to a selected set of features via field calculator and nothing happens. 

I have also noticed some oddities, such as the att table does not open at all (locks up) or I have to resize the bottom of the frame and then it appears. 

I have also tried to add a new field, and it says it is in use by another application (not true).  This is just a point shp file, about 160k features.  I was able to eventually create a new field and calculate other values for it... but 9.4 seems to not like something.  (same data worked fine in 9.3)

UPDATE:  as a hunch, I tried using a definition query to 'select out' the features I wanted to calculate values for and then tried it... low and behold it worked.  so, seems like there is a conflict to having features selected and trying to use a field calculator on them.... 

thoughts ??



Can you log a Support incident for these issues so that we can investigate further?
0 Kudos
aaronreyna
New Contributor
For 94 beta1, code blocks are not supported for VbScript in the GP CalculateField tool or by right clicking a field in TableView. That is due to the deprecation of VBA of 94. At 93, multiline VB code blocks were actually parsed by VBA, and the single line expression parameter was parsed by VbScript. We do however still support VbScript at 94; but it still only for the single line expression parameter. We are currently investigating VbScript code blocks for 94 to support 93 workflows. For your records, the tracking number to support multiline code blocks in NIM050827.

At beta1, you have to use Python for complex code blocks.

Please let me know if you have any questions about this, or if you run in to any other problems with the 94 field calculator; especially any issues with transitioning 93 workflows to 94.


Jeff, since we are on the topic, can you point me in the direction of an example of multiline VB code blocks for 9.3 with python. I cant find one anywhere since the upgrade. i keep getting an "ERROR 000193: The VB option is not valid for UNIX" error message.

Any help would be greatly appreciated! thanks so much.

Best,

aaron
0 Kudos
BarryGuidry
Occasional Contributor
Hey guys, what I found to be my problem, when receiving this error, was that you can't declare variable types in VBScript. See also my post in VBForums.
0 Kudos