Script to trigger from VI - Problem with Exit Sub function

SOLVED

Hello,

I have been working on a script that launches after a visual integrator job and have run into an issue with the Exit Sub function. I have seen other threads about how you have to define the Sub first when triggering like this but can't quite figure out how to write that into the script. Or another option is to rewrite the script to get rid of the Exit Sub but I wasn't quite sure how to rewrite this one to exclude it. The error I get when triggering from VI is on the Exit Sub function. The script works fine when done as a BOI script. This is on the Sales Order History Detail table. Thanks for any help!

curtrack = ""
alltrack = ""
x = 0
newtrack = ""

retVal = oBusObj.GetValue("UDF_CURTRACK$", curtrack)
retVal = oBusObj.GetValue("UDF_ALLTRACK$", alltrack)

x = InStr(alltrack,curtrack)

If x <> 0 then
Exit Sub
End if

newtrack = alltrack + " , " + curtrack

retVal = oBusObj.SetValue("UDF_ALLTRACK$", newtrack)