Hi there,
Can anyone please have a look in the script below;
If[AssetCondition] = "1 - NEW" Then
[CONDITION] = "1"
ElseIf[AssetCondition] = "2 - GOOD" Then
[CONDITION] = "2"
ElseIf[AssetCondition] = "3 - POOR" Then
[CONDITION] = "3"
ElseIf[AssetCondition] = "4 - UNSERVICEABLE" Then
[CONDITION] = "4"
Else [CONDITION] = "NULL"
End If
It's not working. Any assistance will be highly appreciated, thanks
I have several comments. If you are using the Field Calculator you cannot set a field value in VB Script with an expression like:
[CONDITION] = "1"
You can only set a field value by doing a calculation on that field. Field names in brackets are read only.
You need to make the output of the calculation a variable name, not a field name. I use the variable Output in all my Pre-Logic VB calculations. You need a space after keywords like If and ElseIf. Else should be by itself in a multiline If Else Then expression. Null is not quoted if you want a real Null value.
Here is the Field Calculator set up you need to use while doing the calculation on the CONDITION field:
Parser: VB Script
Show Codeblock checked
Pre-Logic Script Code:
If [AssetCondition] = "1 - NEW" Then
Output = "1"
ElseIf [AssetCondition] = "2 - GOOD" Then
Output = "2"
ElseIf [AssetCondition] = "3 - POOR" Then
Output = "3"
ElseIf [AssetCondition] = "4 - UNSERVICEABLE" Then
Output = "4"
Else
Output = Null
End If
CONDITION =
Output