An exact solution is given for the problem of determining the ground state of a charge particle in a zero range force field located in a quantum well and in a magnetic field. The dependence of the electron's ground state on the potential depth and the magnetic field is investigated in a semiconductor layer of an arbitrary width. In particular, it is shown that in the twodimensional case the bound state exists in potential at the definite relation between the scattering length, the magnetic length, and the layer width, in contrast to the three-dimensional case, where the bound state always exists in an arbitrary potential in the magnetic field.