Scatterplot Outliers

#1
Looking for Visual Basic Code to detect outliers in a scatter plot. I suspect that I need to calculate the distances of each point to the regression line. If so, then what?
What would the formula involved look like. Thanks.