crystalcarreon

VB conditional statement not working in calculate field tool

Discussion created by crystalcarreon on May 24, 2011
Latest reply on Jul 6, 2011 by PGrimesesri-ireland-ie-esridist
I am writing a python script which utilizes the expression & code block parameter in the calculate field tool to populate values for a specific field. The code block uses a conditional If,Then, Else statement to understand the value of an existing field (Num_Value) in order to calculate the value of another field (Num_Text). However, I keep receiving the error "(Microsoft VBScript compilation error) Expected end of statement". See script below:
...
CodeBlock = "dim X as string \\nIf [Num_Value] = 1 Then \\nX = \"Poor\" \\nElse X = \"Good\" \\nEnd If"
gp.CalculateField_management(InputFeature,"Num_Text","X","VB",CodeBlock)
...

Any ideas as to what I am doing wrong within the VB code block??
Any help is greatly appreciated!
Thanks!

P.S. Using arcmap 9.2

Outcomes