We present a simple and efficient numerical method to compute the eigenvalues and eigenfunctions of two-dimensional billiards subjected to a constant magnetic field in the perpendicular direction. As examples we present results for the circular billiard, where the method is particularly simple, and for the square billiard, which is nonintegrable for nonzero fields.