Solved! Go to Solution.
Ok. I missed that your code had at least 3 syntax errors. I overlooked them, because the syntax is so basic. “AND” is a Logical Operators used to link expressions that evaluate to True or False (See this link for logical operator help<http://msdn.microsoft.com/en-us/library/4ah2h0k3(v=vs.84).aspx>). You have to use “>=” not “= >” (See this link for comparison operators<http://msdn.microsoft.com/en-us/library/9hck4s70(v=vs.84).aspx>). You have to use “ElseIf” not “Else If” (See this link for If Else Then syntax<http://msdn.microsoft.com/en-us/library/5h27x7e9(v=vs.84).aspx>). You should study this MSDN website and learn more about VB Script syntax.
If <= 1000 Then
Output = "I"
Elseif > 1000 AND <= 3000 Then
Output = "II"
Elseif > 3000 AND <= 5000 Then
Output = "III"
Elseif > 5000 AND <= 10000 Then
Output = "IV"
Elseif > 10000 Then
Output = "V"
Else
Output = "xxx"
End If
Dear tech Support Team,
I am working on table i want some correction in script for calculating field
I have Data in Grid_code field in the form of 1 to 6
In grid_code field there is value 1 to 6 i want 1 is convert as Very low, 2 Is Low, 3 is Moderate, 4 is High and 5 is Very high in Class field i am using following script
Dim Output as String
If [Class] = 1 Then
Output = "Very Low"
Elseif [Class] = 2 Then
Output = "Low"
Elseif [Class] = 3 Then
Output = "Moderate"
Elseif [Class] = 4 Then
Output = "High"
Elseif [Class] = 5 Then
Output = "Very High"
Elseif [Class] = 6 Then
Output = "Extreme"
Else
Output = "xxx"
end if
Please help me to correct this script or please tell me where i get solution
Thanks & Regards
Abhishek Misra
If [Class] = 1 Then Output = "Very Low" Elseif [Class] = 2 Then Output = "Low" Elseif [Class] = 3 Then Output = "Moderate" Elseif [Class] = 4 Then Output = "High" Elseif [Class] = 5 Then Output = "Very High" Elseif [Class] = 6 Then Output = "Extreme" Else Output = "xxx" End If
Dear Richard
once again i am stuck in a similar kind of script please help me my script is
If [Area_ha]= < 1000 Then
Output = "I"
Else if [Area_ha] > 1000 & [Area_ha]= < 3000 Then
Output = "II"
Else if [Area_ha] > 3000 & [Area_ha]= < 5000 Then
Output = "III"
Else if [Area_ha] > 5000 & [Area_ha]= < 10000 Then
Output = "IV"
Else if [Area_ha] > 10000 Then
Output = "V"
Else
Output = "xxx"
end if
Thanks & Regards
Abhishek
Thanks For your quick reply
but i am unable to understand your point i want to calculate field in between 1000 to 3000 as II
so what kind of logical expression will be use for this
Regards
Abhishek
Abhishek,
You have to use the word AND in your script not the ampersand '&' symbol:
Else if [Area_ha] > 1000 AND [Area_ha]= < 3000 Then
Regards
Anthony
Ok. I missed that your code had at least 3 syntax errors. I overlooked them, because the syntax is so basic. “AND” is a Logical Operators used to link expressions that evaluate to True or False (See this link for logical operator help<http://msdn.microsoft.com/en-us/library/4ah2h0k3(v=vs.84).aspx>). You have to use “>=” not “= >” (See this link for comparison operators<http://msdn.microsoft.com/en-us/library/9hck4s70(v=vs.84).aspx>). You have to use “ElseIf” not “Else If” (See this link for If Else Then syntax<http://msdn.microsoft.com/en-us/library/5h27x7e9(v=vs.84).aspx>). You should study this MSDN website and learn more about VB Script syntax.
If <= 1000 Then
Output = "I"
Elseif > 1000 AND <= 3000 Then
Output = "II"
Elseif > 3000 AND <= 5000 Then
Output = "III"
Elseif > 5000 AND <= 10000 Then
Output = "IV"
Elseif > 10000 Then
Output = "V"
Else
Output = "xxx"
End If
Thanks Richerd Script is working fine
Regards
Abhishek
The code you have written should work if you get rid of the line that says Dim Output as String. VB Script does not use DIM anymore and it is not even necessary if you are using VBA with ArcMap 9.3 (but then the ElseIf needs to be changed to Else If for VBA). Make sure you do the calculate to a text field with enough characters to accept the values you want it output and the make sure the field expression is the word Output. If the Class field is numeric you can't use the field calculator to overwrite that field to a text value and would have to create a new field.If [Class] = 1 Then Output = "Very Low" Elseif [Class] = 2 Then Output = "Low" Elseif [Class] = 3 Then Output = "Moderate" Elseif [Class] = 4 Then Output = "High" Elseif [Class] = 5 Then Output = "Very High" Elseif [Class] = 6 Then Output = "Extreme" Else Output = "xxx" End If
Expression: Output