We show that the procedure used by Ferreira et al. [Phys. Rev. A 66, 024103 (2002)] is not correct for the following reasons: (i) the invariant
I(t) they derived does not satisfy the Liouville--Von Neuman equation. (ii) They found that the eigenvalues of
I(t) are time dependent which should not be the case according to the Lewis-Riesenfeld theory. We give a correct procedure to find the solution of the system they considered, i.e., the Schr\"odinger equation for a two-dimensional harmonic oscillator with time-dependent mass and frequency in the presence of a static magnetic field.