Distance between two objects

Hi! Can any one tell me how can I determine the distance between two objects?

I need to make an object (A) to follow one other (B) if this one is close to him.

Thanks in advance.