The nature of instability occurring in a differentially heated infinite slot under steady gravity depends only on the Prandtl number of the contained Boussinesq fluid. For fluids with Pr < 12.5, the instability is shear dominated and onsets in a steady convection mode; for fluids with Pr > 12.5, the instability is buoyancy dominated and onsets in an oscillatory mode. In this paper, we examine the effect of gravity modulation on the stability characteristics of convection in an infinite slot with both kinds of fluids, in particular, Pr = 1 and Pr = 25. Using the method of Sinha & Wu (1991), we are able to obtain accurate results without excessive numerical integration in the linear stability analysis by Floquet theory. Results show that, for Pr = 1, at a non-dimensional oscillation frequency ω = 20, the critical state alternates between the synchronous and subharmonic modes. At higher frequencies, ω > 100, all critical states occur in the synchronous mode. For Pr = 25, with a modulation amplitude ratio of 0.5, resonant interaction occurs in the neighbourhood of ω = 2σc, where σc is the oscillation frequency of the instability at the critical state under steady gravity. This resonant interaction is destabilizing, with the critical Grashof number being reduced by approximately 20% from that at steady gravity. It is due to the presence of a detached subharmonic branch of the marginal stability curve. In frequency ranges where the detached subharmonic branch is absent, the critical state is in the quasi-periodic mode consisting of two waves of different oscillation frequencies whose sum is the forcing frequency. An analysis of the rate of change of the perturbation kinetic energy shows that, for Pr = 1, the instability is shear dominated regardless of the mode of oscillation, synchronous or subharmonic. Similarly, for Pr = 25, the instability is buoyancy dominated whether it is in the quasi-periodic or subharmonic mode. The mode switching is a response to the forcing and is independent of the dominant mechanisms of instability.