I think you need to show some effort in code before anyone will help you.
BTW, that is not a good way of finding the angle between two lines computationally. If either B is zero then the corresponding gradient m1 or m2 will be infinite, making it very difficult to handle. Better is to note that (A1,B1,0) and (A2,B2,0) give normals to the two lines. The angle between these normals is the same as the angle between the lines, and can be recovered by expressing their scalar product in terms of the cosine of the angle.