VB Error 6 on line 0 expected statement

623
1
06-07-2017 08:07 AM
GrantHaynes
Occasional Contributor

Hi everyone, I've been tasked with labeling some soil borings with the corresponding analytical data. I wrote out a VB script with multiple if then statements to concatenate strings with the analytical values and replace any 0s in the data with a "ND" or non detect. Whenever I try to run the script I get "error 6 on line 0 expected statement" or "error 5 on line 0 expected statement"  I've checked all the if/then statements, and I've even tried pairing it down to just one statement to try to troubleshoot the rest, I can't seem to find anything wrong, I'm hoping someone here can help me out.

Function FindLabel( [Shallow_GRO], [Shallow_DRO], [Shallow_ORO], [Shallow_PNA], [Deep_GRO], [Deep_DRO], [Deep_ORO], [Deep_PNAs])
if ([Shallow_GRO]>0)then
FindLabel = FindLabel &vbnewline& "GRO" & [Shallow_GRO]
elseif ([Shallow_GRO]=0) then
FindLabel = FindLabel &vbnewline& "ND"
endif
if ([Shallow_DRO] > 0)then
FindLabel = FindLabel&vbnewline& "DRO" & [Shallow_DRO]
elseif ([Shallow_DRO]=0) then
FindLabel = FindLabel &vbnewline& "ND"
endif
if ([Shallow_ORO]>0)then
FindLabel = FindLabel&vbnewline& "ORO" & [Shallow_ORO]
elseif ([Shallow_ORO]=0) then
FindLabel = FindLabel &vbnewline& "ND"
endif
if ([Shallow_PNA]>0)then
FindLabel = FindLabel&vbnewline& "PNA" & [Shallow_PNA]
elseif ([Shallow_PNA]=0) then
FindLabel = FindLabel &vbnewline& "ND"
endif
if ([Deep_GRO]>0)then
FindLabel = FindLabel&vbnewline& "GRO" & [Deep_GRO]
elseif ([Deep_GRO]=0) then
FindLabel = FindLabel &vbnewline& "ND"
endif
if ([Deep_DRO]>0)then
FindLabel = FindLabel&vbnewline& "DRO" & [Deep_DRO]
elseif ([Deep_DRO]=0) then
FindLabel = FindLabel &vbnewline& "ND"
endif
if ([Deep_ORO]>0)then
FindLabel = FindLabel&vbnewline& "ORO" & [Deep_ORO]
elseif ([Deep_ORO]=0) then
FindLabel = FindLabel &vbnewline& "ND"
endif
if ([Deep_PNAs]>0)then
FindLabel = FindLabel&vbnewline& "PNA" & [Deep_PNAs]
elseif ([Deep_PNAs]=0) then
FindLabel = FindLabel &vbnewline& "ND"
endif
End Function

Tags (2)
0 Kudos
1 Reply
GrantHaynes
Occasional Contributor

Never mind I figured it out, endif needs to be end if