Skip to content
+1-888-319-3663

COMMUNITY FORUM

Nested if statement

Brenda Hopkins asked 7 months ago
I am getting Error in calculation: Syntax error. and End of Statement Expected.   I add multiple End If statements but that is not helping me.
My Calculation:
If (_WORKEDWG2CODE =”2010″ AND _WORKEDWG3CODE  =”2600″ )
return “TIP160”
 (  Elseif (_WORKEDWG2CODE =””2010″” AND _WORKEDWG3CODE  =”2620″ )
return “TIP010”
   Elseif (_WORKEDWG2CODE =”2015″ AND _WORKEDWG3CODE  =”2600″ )
return “TIP680”
   Elseif (_WORKEDWG2CODE =”2015″ AND _WORKEDWG3CODE  =”2610″)
 return “TIP240”
   Elseif (_WORKEDWG2CODE =”2015″ AND _WORKEDWG3CODE  =”2700″ )
return “TIP180”
   Elseif (_WORKEDWG2CODE =”2030″ AND _WORKEDWG3CODE  =”2600″ )
return “TIP260”
   Elseif (_WORKEDWG2CODE =”2030″ AND _WORKEDWG3CODE  =”2620″ )
return “TIP020”
   Elseif (_WORKEDWG2CODE =”2110″ AND _WORKEDWG3CODE  =”2700″ )
return “TIP200”
   Elseif (_WORKEDWG2CODE =”2110″ AND _WORKEDWG3CODE  =”2710″ )
return “TIP050”
   Elseif (_WORKEDWG2CODE =”2110″ AND _WORKEDWG3CODE  =”2720″ )
return “TIP220”
   Elseif (_WORKEDWG2CODE =”2110″ AND _WORKEDWG3CODE  =”2725″ )
return “TIP220”
   Elseif (_WORKEDWG2CODE =”2110″ AND _WORKEDWG3CODE  =”2730″ )
return “TIP220”
   Elseif (_WORKEDWG2CODE =”3010″ AND _WORKEDWG3CODE  =”3110″ )
return “TIP040”
   Elseif (_WORKEDWG2CODE =”9550″ AND _WORKEDWG3CODE  =”2600″ )
return “TIP220”
   Elseif (_WORKEDWG2CODE =”9550″ AND _WORKEDWG3CODE  =”2620″ )
return “TIP070”
   Elseif (_WORKEDWG2CODE =”9550″ AND _WORKEDWG3CODE  =”2700″)
return “TIP375”)
Else Return “0.00”
End if
 
Answers
Patrick Roth Staff answered 7 months ago
I see a number of problems with the code. 
When you get compilation errors, the first easy debug step is make the code simpler and test.  And then add, and test, etc.
 
If (_WORKEDWG2CODE =”2010″ AND _WORKEDWG3CODE  =”2600″ )
return “TIP160”
End if
 
so I’d think this would work.
Then you add your next line, and it should fail so you would concentrate on that line.
 (  Elseif (_WORKEDWG2CODE =””2010″” AND _WORKEDWG3CODE  =”2620″ )
return “TIP010”
 
What’s different on this one (compared to the first and every other “elseif” line that you had)?
You put a leading parens around the first line- that is incorrect.
The others look pretty good until you get here:
 
return “TIP375”)
Else Return “0.00”
End if
 
We have the extra ) on the TIP375 line.  Although now that I see that one extra and the second line – you tried to enclose the whole thing in parens.  Nope, incorrect.

The last thing that I think might not work:

Else Return “0.00”

vb.net is picky about where you place code on certain lines.  So i wouldn’t be surprised if this also fails (which we note is different than the other “elseif” lines.

should probably be:
else
return “0.00”
 
Different lines instead of one line as you had it.
patrick

If you would like to submit an answer or comment, please sign in to the eOne portal.