perhaps it would be easier if you draw/do the problem on paper first.
you're problem right now is that you know the x line and y line of a triangle between the two points (absolute difference between x1 and x2 = x line, same with y)
so you know two sides of a triangle of which one angle is 90 degrees.
all you need to do now is calculate the hypotenuse (diagonal side)
which as stated earlier is easy using
a^2 + b^2 = c^2 (xline^2 + yline^2 = hypotenuse^2)
here's a picture from wikipedia
so after that just get the square root of c and there you go, the length of the hypotenuse which is the distance between the two points
(in case you don't quite get which point is which, corner a c is the coordinates of 1 point, a b is were xline and yline meet, and b c is the coordinates of your second point)