[GIS] Field Calculator VB Script Codeblock IF statement syntax is wrong

arcgis-10.0arcgis-desktoparcmapfield-calculatorvbscript

I can't figure out why the syntax is wrong in Field Calculator ArcMap 10. The complete codeblock is

Dim CapitalDia As Number
Dim TwagDia As Number
Dim X As Number

CapitalDia = [New_Pipe_S]
TwagDia = [DIAMETER_1]

If CapitalDia= 0 Then
 X = TwagDia
Else
 X = CapitalDia
End If

And then, the bottom window is

Final_Dia = 
X

Best Answer

The "as Number" is what's causing the error. Just use "dim X"

dim X

if [New_Pipe_S] = 0 then
 X = [DIAMETER_1]
else
 X = [New_Pipe_S]
end if
Related Question