On the motion of charged particles in a varying magnetic field