I'll assume your talking about points and lines in the plane. For 3-space its the same idea just a little longer. Also I'm writing in the notation of vector curves, but it can be adapted to standard equations for lines. All capital letters indicate vectors, lowercase are scalar quantities.

So suppose you have a point Q = <x,y> and a line L(t) = P + t*V, where P is a point and V is a direction vector -- assume for simplicity that V is a unit vector. To find the distance from Q to L is to find the distance from Q to N, where N is a point on the line that minimizes distance to Q. This will happen of course precisely when the vector (Q - N) meets the direction vector V at a right angle, i.e., when

(Q - N) dot V = 0 (dot is the vector dot product)

i.e., find t such that:

(Q - P - t*V) dot V = 0

expanding:

= Q dot V - P dot V - t*V dot V = Q dot V - P dot V - t

= (Q - P) dot V - t = 0,

OR:

t = (Q - P) dot V

Thus N = L(t), where t = (Q - P) dot V, so simply find the distance from Q to N (the standard Euclidean distance formula).